udevd: Init signal pipe before forking to background
PATCH 1/1 udevd: Init signal pipe before forking to background
Signal pipe setup may fail - perform it before forking to background, so that the parent process may notice the startup failure.
--- udevd.c | 58 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 29 insertions(+), 29 deletions(-)
udevd.c +29 -29
@@ -1006,6 +1006,35 @@ int main(int argc, char *argv[], char *envp[]) goto exit; } +/* setup signal handler pipe */ + retval =pipe (signal_pipe); +if (retval <0 ) { +err ("error getting pipes: %s" ,strerror (errno)); + goto exit; + } + + retval =fcntl (signal_pipe[READ_END ],F_GETFL ,0 ); +if (retval <0 ) { +err ("error fcntl on read pipe: %s" ,strerror (errno)); + goto exit; + } + retval =fcntl (signal_pipe[READ_END ],F_SETFL , retval |O_NONBLOCK ); +if (retval <0 ) { +err ("error fcntl on read pipe: %s" ,strerror (errno)); + goto exit; + } + + retval =fcntl (signal_pipe[WRITE_END ],F_GETFL ,0 ); +if (retval <0 ) { +err ("error fcntl on write pipe: %s" ,strerror (errno)); + goto exit; + } + retval =fcntl (signal_pipe[WRITE_END ],F_SETFL , retval |O_NONBLOCK ); +if (retval <0 ) { +err ("error fcntl on write pipe: %s" ,strerror (errno)); + goto exit; + } +/* parse the rules and keep them in memory */ sysfs_init ();udev_rules_init (&rules,1 );
@@ -1062,35 +1091,6 @@ int main(int argc, char *argv[], char *envp[])close (fd); } -/* setup signal handler pipe */ - retval =pipe (signal_pipe); -if (retval <0 ) { -err ("error getting pipes: %s" ,strerror (errno)); - goto exit; - } - - retval =fcntl (signal_pipe[READ_END ],F_GETFL ,0 ); -if (retval <0 ) { -err ("error fcntl on read pipe: %s" ,strerror (errno)); - goto exit; - } - retval =fcntl (signal_pipe[READ_END ],F_SETFL , retval |O_NONBLOCK ); -if (retval <0 ) { -err ("error fcntl on read pipe: %s" ,strerror (errno)); - goto exit; - } - - retval =fcntl (signal_pipe[WRITE_END ],F_GETFL ,0 ); -if (retval <0 ) { -err ("error fcntl on write pipe: %s" ,strerror (errno)); - goto exit; - } - retval =fcntl (signal_pipe[WRITE_END ],F_SETFL , retval |O_NONBLOCK ); -if (retval <0 ) { -err ("error fcntl on write pipe: %s" ,strerror (errno)); - goto exit; - } -/* set signal handlers */ memset (&act,0x00 ,sizeof (struct sigaction )); act.sa_handler = (void (*)(int )) sig_handler;
Signature · 12 lines
1.5.0.rc1.gbcae ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV _______________________________________________ Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net [email protected] https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel
Kay Sievers
AppliedQuoted 2 lines · Sergey Vlasov
Signal pipe setup may fail - perform it before forking to background, so that the parent process may notice the startup failure.
Applied.
Thanks,
Kay
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CIDÞVDEV
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel