Clone flags

The clone flags determine a whole range of properties of the child process. They are defined in <linux/sched.h>, as shown in Figure 8.10.

#define #define #define #define #define #define #define #define #define #define

CSIGNAL

CLONE_VM

CLONE_FS

CLONE_FILES

CLONE_SIGHAND

CLONE_PID

CLONE_PTRACE

CLONE_VFORK

CLONE_PARENT

CLONE_THREAD

0x000000ff

0x00000100

0x00000200 0x00000400 0x00000800 0x00001000 0x00002000 0x00004000 0x00008000 0x00010000

#define CLONE_SIGNAL (CLONE_SIGHAND | CLONE_THREAD)

Figure 8.10 Clone flags

35 the number of the signal to be sent to the parent process when the child exits is encoded in the low-order 8 bits of the clone flag value. This mask clears the rest of the value.

36 the parent and child are to share the same virtual memory mapping.

37 file system information is to be shared.

38 open files are to be shared.

39 signal handlers are shared.

40 even the pid is shared.

41 the child process is to inherit the traced attribute of its parent (i.e. if the parent was being traced when the child was created, the child will also be traced).

42 this bit is set if it is expected that the child is going to call exec( ) immediately after the fork(). In that case the parent sleeps on the vfork completion. When the child releases its link to the memory it shares with the parent, as part of the implementation of exec(), then it signals that completion and wakes up the parent.

43 this is set if the child is to have the same parent as the cloner (i.e. if it is to be a sibling, not a child).

44 this is set if the call to clone() is actually creating a new thread in an existing process.

46 this is a common combination, so it is given a name of its own. It means that the new thread is to share signal handlers with the creating thread.

Continue reading here: Saving registers

Was this article helpful?

0 0