php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #24616 Process started with "exec cmd > /dev/null &" dies when httpd is closed
Submitted: 2003-07-12 01:00 UTC Modified: 2003-07-13 21:28 UTC
From: carb at videotron dot ca Assigned:
Status: Not a bug Package: Apache related
PHP Version: 4.3.2 OS: RedHat 9.0
Private report: No CVE-ID: None
 [2003-07-12 01:00 UTC] carb at videotron dot ca
Description:
------------
When forking off a process from PHP with the statement exec("command > /dev/null &"), the process will get killed when the httpd is closed.   

Note: This occurs even though ps is telling me that the parent process id is init (parent process id 1).


Reproduce code:
---------------
<?PHP
  
  session_write_close();  

  //Simple example to reproduce problematic forking.
  exec("ping localhost > /dev/null &");
   
?>

Expected result:
----------------
A continuous ping process should be running in the backgroud, independently of httpd.  When httpd is closed, the ping (or whatever relevant) process should keep running.

Actual result:
--------------
When httpd is closed, the ping (or whatever relevant) process dies.

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-07-12 01:07 UTC] carb at videotron dot ca
Same behavior with:

<?PHP
  session_write_close(); 
  
  //Simple example to reproduce problematic forking
  exec("ping localhost </dev/null >/dev/null 2>/dev/null &");

   
?>
 [2003-07-13 00:02 UTC] sniper@php.net
This is a feature, not bug. (look in bug #15529 for another perpective.. :)

 [2003-07-13 20:45 UTC] carb at videotron dot ca
Ok, that bug is informative, but why not fork off child processes as completely seperate from httpd so that they can really run in the background seperately from the parent?  Such as a double fork to ophan off the process.

I don't think that people who forks off a background process from httpd/php with the "&" expect it to die if/when httpd happens to be restarted or closed.

Real
 [2003-07-13 21:28 UTC] sniper@php.net
Please study fork() a bit more. :)

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 21:01:28 2024 UTC