开发者

Howto pipe to perl a daemon in execution

I know how to pipe to a开发者_如何学编程 perl script just executing something like this:

command | script.pl

Inside the script.pl I got the:

while(<STDIN>){...

and so on, but I demonized the script and i want to know how can I pipe a command to the script while is running like a daemon.

Any suggestion?

Thank you


STDIN should be closed on daemonization for security reasons.

You need to create a socket (or perhaps a fifo) and read from that. I would suggest Unix domain sockets, see chapter 17.6 of the Perl Cookbook.

It is difficult to be more precise from here, as it depends on what your daemon does.


Update:

Actually, now that I think about it, if the program is run on a *nix box you could keep your script as it is and use inetd instead. Inetd will listen to a socket for you and start your daemon on connection, bridging between the socket and STDIN/STDOUT on your program. I have no experience with using inetd with domain sockets, but superficial googling indicates that at least some implementations support domain sockets.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜