I was having some weird problems with tenshi, which I believe are the result of tenshi leaking stdin to the child tail process (wedges in scripts restarting the service, ssh sessions not exiting after starting the process by hand, etc.) Reviewing the code, it appears the pipe to tail is opened before all of the standard file descriptors are closed? Presumably this is because you want stderr available in case you need to generate an error message? It does not appear to be leaking stderr or stdout, only stdin. Maybe the fix could be closing stdin before opening the pipe to tail, and the output file descriptors afterwards? Here is lsof output demonstrating the leak: COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME tail 3761 tenshi cwd DIR 8,1 4096 2 / tail 3761 tenshi rtd DIR 8,1 4096 2 / tail 3761 tenshi txt REG 254,0 39632 245786 /usr/bin/tail tail 3761 tenshi mem REG 0,0 0 [heap] (stat: No such file or directory) tail 3761 tenshi mem REG 8,1 134973 87875 /lib64/ld-2.4.so tail 3761 tenshi mem REG 8,1 1282136 87876 /lib64/libc-2.4.so tail 3761 tenshi 0u CHR 136,0 2 /dev/pts/0 tail 3761 tenshi 1w FIFO 0,5 724129 pipe tail 3761 tenshi 2w FIFO 0,5 724012 pipe tail 3761 tenshi 3r REG 254,3 9999 213137 /var/log/messages
In the next version we'll close STDIN just to make sure. Anyway I fail to see how this could be a problem, tail reads its own FD for opening the log file, how could it be affected by the inherited open STDIN? What kind of "weird problems" are you referring to? P.S. the project moved to http://dev.inversepath.com/trac/tenshi
Fixed in our repo, still think this can't be an issue. Closing the bug for now, please report the "weird problems" and any issue to tenshi@inversepath.com.
Thank you for following up on this. Even if there are no obvious issues, leaking file descriptors is a bad practice, so it's just as well fixed. One issue I most definitely had was that when I logged in via secure shell and started tenshi, when I went to logout, the session hung because the secure shell daemon would not close the connection while there was still a process listening on the open file descriptor. Once I made sure that the stdin file descriptor was closed before forking tail, this problem went away. I also had a problem starting tenshi from a cfengine script, cfagent would wedge after running tenshi, I think because of the same issue. I was having some other issues with tenshi failing to stop that turned out not to be related to the file descriptor. I will follow up with you on those issues with the e-mail address given, thanks...