What properties of an unprivileged process are preserved during an `execve` call?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
1
down vote

favorite
1












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?










share|improve this question

























    up vote
    1
    down vote

    favorite
    1












    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?










    share|improve this question























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      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?










      share|improve this question













      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






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Sep 22 at 19:49









      Josiah Yoder

      1786




      1786




















          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.






          share|improve this answer




















          • 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











          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "106"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          convertImagesToLinks: false,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          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






























          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.






          share|improve this answer




















          • 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















          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.






          share|improve this answer




















          • 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













          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.






          share|improve this answer












          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.







          share|improve this answer












          share|improve this answer



          share|improve this answer










          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

















          • 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


















           

          draft saved


          draft discarded















































           


          draft saved


          draft discarded














          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













































































          Popular posts from this blog

          How to check contact read email or not when send email to Individual?

          Bahrain

          Postfix configuration issue with fips on centos 7; mailgun relay