What properties of an unprivileged process are preserved during an `execve` call?
Clash Royale CLAN TAG#URR8PPP
up vote
1
down vote
favorite
I am teaching an Operating Systems course and trying to wrap my mind around the fork
/execve
technique for creating new processes.
My current understanding is that a fork make a complete copy of the old process, establishes a new PID and parent/child relationship, but otherwise does very little else.
On the other hand, after the child process is created, it runs execve to replace most of its memory with the new process. For example, the program code, stack, and heap are completely replaced and started from scratch as a new program.
But not everything is replaced in the new process. The child process inherits file descriptors (which allows pipes to be set up before the execve), the process ID (PID) and user ID (UID) and some permissions (man page).
I imagine the full list of properties that are NOT replaced by an execve call is quite long, but are there any other key properties like the ones I mentioned above that I'm missing?
linux process exec capabilities
add a comment |Â
up vote
1
down vote
favorite
I am teaching an Operating Systems course and trying to wrap my mind around the fork
/execve
technique for creating new processes.
My current understanding is that a fork make a complete copy of the old process, establishes a new PID and parent/child relationship, but otherwise does very little else.
On the other hand, after the child process is created, it runs execve to replace most of its memory with the new process. For example, the program code, stack, and heap are completely replaced and started from scratch as a new program.
But not everything is replaced in the new process. The child process inherits file descriptors (which allows pipes to be set up before the execve), the process ID (PID) and user ID (UID) and some permissions (man page).
I imagine the full list of properties that are NOT replaced by an execve call is quite long, but are there any other key properties like the ones I mentioned above that I'm missing?
linux process exec capabilities
add a comment |Â
up vote
1
down vote
favorite
up vote
1
down vote
favorite
I am teaching an Operating Systems course and trying to wrap my mind around the fork
/execve
technique for creating new processes.
My current understanding is that a fork make a complete copy of the old process, establishes a new PID and parent/child relationship, but otherwise does very little else.
On the other hand, after the child process is created, it runs execve to replace most of its memory with the new process. For example, the program code, stack, and heap are completely replaced and started from scratch as a new program.
But not everything is replaced in the new process. The child process inherits file descriptors (which allows pipes to be set up before the execve), the process ID (PID) and user ID (UID) and some permissions (man page).
I imagine the full list of properties that are NOT replaced by an execve call is quite long, but are there any other key properties like the ones I mentioned above that I'm missing?
linux process exec capabilities
I am teaching an Operating Systems course and trying to wrap my mind around the fork
/execve
technique for creating new processes.
My current understanding is that a fork make a complete copy of the old process, establishes a new PID and parent/child relationship, but otherwise does very little else.
On the other hand, after the child process is created, it runs execve to replace most of its memory with the new process. For example, the program code, stack, and heap are completely replaced and started from scratch as a new program.
But not everything is replaced in the new process. The child process inherits file descriptors (which allows pipes to be set up before the execve), the process ID (PID) and user ID (UID) and some permissions (man page).
I imagine the full list of properties that are NOT replaced by an execve call is quite long, but are there any other key properties like the ones I mentioned above that I'm missing?
linux process exec capabilities
linux process exec capabilities
asked Sep 22 at 19:49
Josiah Yoder
1786
1786
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
Since weâÂÂre discussing Linux specifically (at least, I take it thatâÂÂs what you want since you used the linux tag), the fork
and execve
manpages are the appropriate references; they list all the attributes which arenâÂÂt preserved. Most of this behaviour is specified by POSIX, but there are some Linux specificities.
The man pages donâÂÂt list attributes which are preserved, focusing instead on those which arenâÂÂt:
All process attributes are preserved during an
execve()
, except the following:
etc.
I wonâÂÂt try to answer your question by listing all the attributes which are preserved. However I will point out one key property which is preserved, and which you havenâÂÂt listed: ignored and default signals are preserved across execve
. This means that a parent can ignore a signal (at least, signals that can be ignored) and that behaviour will be propagated to any children. This is what allows nohup
to work.
I like the comment at the end of the execve man page you recommended: 'One sometimes sees execve() ... described as "executing a new process" ... This is a highly misleading description: there is no new process; many attributes of the calling process remain unchanged (in particular, its PID). All that execve(2) does is arrange for an existing process(the calling process) to execute a new program' An example of how the docs can be very newbie-friendly!
â Josiah Yoder
Sep 24 at 18:30
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
Since weâÂÂre discussing Linux specifically (at least, I take it thatâÂÂs what you want since you used the linux tag), the fork
and execve
manpages are the appropriate references; they list all the attributes which arenâÂÂt preserved. Most of this behaviour is specified by POSIX, but there are some Linux specificities.
The man pages donâÂÂt list attributes which are preserved, focusing instead on those which arenâÂÂt:
All process attributes are preserved during an
execve()
, except the following:
etc.
I wonâÂÂt try to answer your question by listing all the attributes which are preserved. However I will point out one key property which is preserved, and which you havenâÂÂt listed: ignored and default signals are preserved across execve
. This means that a parent can ignore a signal (at least, signals that can be ignored) and that behaviour will be propagated to any children. This is what allows nohup
to work.
I like the comment at the end of the execve man page you recommended: 'One sometimes sees execve() ... described as "executing a new process" ... This is a highly misleading description: there is no new process; many attributes of the calling process remain unchanged (in particular, its PID). All that execve(2) does is arrange for an existing process(the calling process) to execute a new program' An example of how the docs can be very newbie-friendly!
â Josiah Yoder
Sep 24 at 18:30
add a comment |Â
up vote
4
down vote
accepted
Since weâÂÂre discussing Linux specifically (at least, I take it thatâÂÂs what you want since you used the linux tag), the fork
and execve
manpages are the appropriate references; they list all the attributes which arenâÂÂt preserved. Most of this behaviour is specified by POSIX, but there are some Linux specificities.
The man pages donâÂÂt list attributes which are preserved, focusing instead on those which arenâÂÂt:
All process attributes are preserved during an
execve()
, except the following:
etc.
I wonâÂÂt try to answer your question by listing all the attributes which are preserved. However I will point out one key property which is preserved, and which you havenâÂÂt listed: ignored and default signals are preserved across execve
. This means that a parent can ignore a signal (at least, signals that can be ignored) and that behaviour will be propagated to any children. This is what allows nohup
to work.
I like the comment at the end of the execve man page you recommended: 'One sometimes sees execve() ... described as "executing a new process" ... This is a highly misleading description: there is no new process; many attributes of the calling process remain unchanged (in particular, its PID). All that execve(2) does is arrange for an existing process(the calling process) to execute a new program' An example of how the docs can be very newbie-friendly!
â Josiah Yoder
Sep 24 at 18:30
add a comment |Â
up vote
4
down vote
accepted
up vote
4
down vote
accepted
Since weâÂÂre discussing Linux specifically (at least, I take it thatâÂÂs what you want since you used the linux tag), the fork
and execve
manpages are the appropriate references; they list all the attributes which arenâÂÂt preserved. Most of this behaviour is specified by POSIX, but there are some Linux specificities.
The man pages donâÂÂt list attributes which are preserved, focusing instead on those which arenâÂÂt:
All process attributes are preserved during an
execve()
, except the following:
etc.
I wonâÂÂt try to answer your question by listing all the attributes which are preserved. However I will point out one key property which is preserved, and which you havenâÂÂt listed: ignored and default signals are preserved across execve
. This means that a parent can ignore a signal (at least, signals that can be ignored) and that behaviour will be propagated to any children. This is what allows nohup
to work.
Since weâÂÂre discussing Linux specifically (at least, I take it thatâÂÂs what you want since you used the linux tag), the fork
and execve
manpages are the appropriate references; they list all the attributes which arenâÂÂt preserved. Most of this behaviour is specified by POSIX, but there are some Linux specificities.
The man pages donâÂÂt list attributes which are preserved, focusing instead on those which arenâÂÂt:
All process attributes are preserved during an
execve()
, except the following:
etc.
I wonâÂÂt try to answer your question by listing all the attributes which are preserved. However I will point out one key property which is preserved, and which you havenâÂÂt listed: ignored and default signals are preserved across execve
. This means that a parent can ignore a signal (at least, signals that can be ignored) and that behaviour will be propagated to any children. This is what allows nohup
to work.
answered Sep 22 at 20:30
Stephen Kitt
148k23326394
148k23326394
I like the comment at the end of the execve man page you recommended: 'One sometimes sees execve() ... described as "executing a new process" ... This is a highly misleading description: there is no new process; many attributes of the calling process remain unchanged (in particular, its PID). All that execve(2) does is arrange for an existing process(the calling process) to execute a new program' An example of how the docs can be very newbie-friendly!
â Josiah Yoder
Sep 24 at 18:30
add a comment |Â
I like the comment at the end of the execve man page you recommended: 'One sometimes sees execve() ... described as "executing a new process" ... This is a highly misleading description: there is no new process; many attributes of the calling process remain unchanged (in particular, its PID). All that execve(2) does is arrange for an existing process(the calling process) to execute a new program' An example of how the docs can be very newbie-friendly!
â Josiah Yoder
Sep 24 at 18:30
I like the comment at the end of the execve man page you recommended: 'One sometimes sees execve() ... described as "executing a new process" ... This is a highly misleading description: there is no new process; many attributes of the calling process remain unchanged (in particular, its PID). All that execve(2) does is arrange for an existing process(the calling process) to execute a new program' An example of how the docs can be very newbie-friendly!
â Josiah Yoder
Sep 24 at 18:30
I like the comment at the end of the execve man page you recommended: 'One sometimes sees execve() ... described as "executing a new process" ... This is a highly misleading description: there is no new process; many attributes of the calling process remain unchanged (in particular, its PID). All that execve(2) does is arrange for an existing process(the calling process) to execute a new program' An example of how the docs can be very newbie-friendly!
â Josiah Yoder
Sep 24 at 18:30
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f470754%2fwhat-properties-of-an-unprivileged-process-are-preserved-during-an-execve-call%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password