linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* hotplug not opening stdin by default. Is this a bug?
@ 2007-08-07 21:48 Leif Johnson
  2007-08-07 22:16 ` Kay Sievers
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Leif Johnson @ 2007-08-07 21:48 UTC (permalink / raw)
  To: linux-hotplug

Hello,

I ran into a problem that I believe is a bug in hotplug, but others do
not agree.  So I am asking here.

This work is all being done on an embedded device, arm processor.
Linux kernel 2.6.15,  .BusyBox v1.1.3, and libc 2.3.6.

Hotplug does not seem to open fds 0 or 2 on the system (and I'm told
it does not do it on any system).

The bug happens as follows.
1.  Program opens an fd and gets 0 (in this case the fd was for kernel
communication)
2.  The program then calls daemon(0,0).
2a. daemon (with the second 0) opens an fd /dev/null as O_RDWR, then
uses the dup2 call to dup it over stdin, stdout and stderr.  e.g.
dup2(fd, STDIN_FILENO);
dup2(fd, STDOUT_FILENO);
dup2(fd, STDERR_FILENO);
3.  This has now duped the fd for /dev/null over the 0, which was the
fd for kernel communication.  Now the program gets bad communication
from the kernel and exits.

The argument is over whose responsibility it is to properly handle
those fds.  The program or hotplugs.  I would claim it is hotplugs,
because
(1) Programs would not need to behave differently from hotplug or the
command line.  (2) Forcing programs to handle it would lead to *much*
duplicated code and different ad-hoc solutions.  (3) Not changing the
behaviour would force programmers to keep rediscovering this.

My proposal would be to have hotplug send the last 2 fds (0 and 2) to
/dev/null for the programs.  I think this would lead to much more
reasonable behavior.

All coments/suggestions are appreciated.

thanks,
leif

-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >>  http://get.splunk.com/
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2007-08-08  2:48 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-07 21:48 hotplug not opening stdin by default. Is this a bug? Leif Johnson
2007-08-07 22:16 ` Kay Sievers
2007-08-07 23:17 ` Greg KH
2007-08-07 23:47 ` Leif Johnson
2007-08-08  2:48 ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).