stdin/stdout/etc
| From: | William Astle | Date: | Tue, 13 Jan 2004 10:53:39 +0000 |
| Subject: | stdin/stdout/etc | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-174472@lists.php.net to get a copy of this message | ||
There are a couple of things I'm trying to do and I can't find anything in
the documentation that indicates if its possible or not. This is all using
the CLI version.
First, I would like to close all file descriptors, including stdin,
stdout, and stderr. But I can't find any way of doing so. This is for
backgrounding a process. Barring that, redirecting them to /dev/null would
be sufficient. This is the only piece I haven't worked out yet. I know I
could just use "nohup" and all that jazz to start the process up, but I
wanted to make the thing into a "grown up" daemon.
The other thing I wanted to do was to avoid the whole daemonization thing
and run the process from inetd. However, I need to have the remote IP
address of the connection. A likely candidate for doing so would seem to
be socket_getpeername() but I can't do that on a regular file resource
like I would get from opening php://stdin, for example. I also see no way
of doing any socket operation on the stdin/stdout file descriptors at all
which would be immensely useful for this sort of application. I can work
around this with a short C wrapper that executes the script after doing to
socket operations but I'd rather not do this.
--
William Astle
finger lost@l-w.net for further information
Geek Code V3.12: GCS/M/S d- s+:+ !a C++ UL++++$ P++ L+++ !E W++ !N w--- !O
!M PS PE V-- Y+ PGP t+@ 5++ X !R tv+@ b+++@ !DI D? G e++ h+ y?