Re: creating detached processes in PHP
| From: | ilya77@gmail.com | Date: | Tue, 23 Nov 2004 19:56:02 +0000 |
| Subject: | Re: creating detached processes in PHP | ||
| References: | 1 2 3 4 5 6 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-13938@lists.php.net to get a copy of this message | ||
win32: copy the code from proc_open(), just leave the pipes stuff out.
By detached I mean - start and leave running.
for most unixes:
pid = fork();
if (pid == 0)
{
close(0);
close(1);
close(2);
// mask out SIGHUP signal - unfortunately I don't remember the
calls for unixes
exec(...);
}
else if (pid == -1)
{
// fail
return -1;
}
else
{
return pid;
}
On Tue, 23 Nov 2004 01:52:41 -0500, Wez Furlong <kingwez@gmail.com> wrote:
> On Tue, 23 Nov 2004 08:28:03 +0200, ilya77@gmail.com <ilya77@gmail.com> wrote:
> > The bottom line, is that in PHP there is no simple and consistent
> > cross-platform way to create a detached child process.
>
> > Being a system programmer, this shouldn't be too much of an obstacle
> > for me, but at this moment I'm thinking of the application programmers
> > which don't have an api to create detach processes.
>
> Define what you mean by detached and provide an example (in C) of how
> to achieve it on all (well, most will do) unices without assuming the
> presence of utility apps like nohup.
>
> Likewise for win32.
>
> --Wez.
>