[systemd-devel] wrong return value when fork() fail in exec_spawn() ?

eshark eshark77 at 163.com
Thu Nov 26 18:51:18 PST 2015


   Hi, all,

    It seems that  the exec_spawn() will return 0 if fork() fails,  because  that
                return log_unit_error_errno(params->unit_id, errno, "Failed to fork: %m");
 will return -r eventually.  And here r = exec_context_load_environment() , which has 
 exited successfully.

   This may lead big trouble to the caller of  exec_spawn().  For example,  mount_spawn(), which 
also calls exec_spawn(), will not goto fail but run continuelly in this case. Then the following unit_watch_pid()
will fail  at assert(pid >= 1);. 

   I also commit a patch to fix this problem, please help to review.
  
  Thanks a lot!

 Li Cheng

  
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-core-execute-fix-fork-fail-handling-in-exec_spawn.patch
Type: application/octet-stream
Size: 1051 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/systemd-devel/attachments/20151127/71e47235/attachment.obj>


More information about the systemd-devel mailing list