init: "script" stanza leaks file descriptor to child process
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
upstart |
Fix Released
|
Medium
|
Scott James Remnant | ||
upstart (Ubuntu) |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Upstart sends job scripts to shell via pipe represented by /dev/fd/<fd> (/proc/self/fd/) file in proc filesystem, e.g.:
/bin/sh -e /dev/fd/9
This fd stays open while child shell process is running. There are some applications like pvdisplay (and other lvm2 tools) which complaint about it.
How to reproduce:
Boot to runlevel 1
Run pvdisplay:
# pvdisplay
File descriptor 9 (pipe:[9737]) leaked on pvdisplay invocation. Parent PID 845: /bin/bash
--- Physical volume ---
...
Possible solution would be send first closing pipe fd command to shell:
+ close_fd = NIH_MUST (nih_sprintf (NULL, "<&%d- ;", fds[0]));
+ NIH_ZERO (nih_io_write (io, close_fd, strlen (close_fd)));
+
NIH_ZERO (nih_io_write (io, script, strlen (script)));
nih_io_shutdown (io);
Changed in upstart: | |
status: | Triaged → Fix Committed |
assignee: | nobody → Scott James Remnant (scott) |
milestone: | none → 1.1 |
Changed in upstart: | |
status: | Fix Committed → Fix Released |
Changed in upstart (Ubuntu): | |
status: | New → Fix Released |
Good catch, I'm pretty sure I had that <&3-; in there at one point, I must have lost it as I can't see it anywhere in the bzr history