Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 163385 - app-admin/tenshi-0.6 leaks stdin (fd 0) to tail
Summary: app-admin/tenshi-0.6 leaks stdin (fd 0) to tail
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High normal
Assignee: Andrea Barisani (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2007-01-23 02:27 UTC by Paul B. Henson
Modified: 2007-01-25 00:20 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Paul B. Henson 2007-01-23 02:27:16 UTC
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
Comment 1 Andrea Barisani (RETIRED) gentoo-dev 2007-01-23 09:38:45 UTC
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
Comment 2 Andrea Barisani (RETIRED) gentoo-dev 2007-01-23 13:01:47 UTC
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.
Comment 3 Paul B. Henson 2007-01-25 00:20:18 UTC
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...