From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sergey Vlasov Date: Sun, 21 Jan 2007 20:28:43 +0000 Subject: [PATCH] udevd: Init signal pipe before forking to background Message-Id: <11694113233279-git-send-email-vsu@altlinux.ru> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: linux-hotplug@vger.kernel.org Signal pipe setup may fail - perform it before forking to background, so that the parent process may notice the startup failure. Signed-off-by: Sergey Vlasov --- udevd.c | 58 +++++++++++++++++++++++++++++----------------------------- 1 files changed, 29 insertions(+), 29 deletions(-) diff --git a/udevd.c b/udevd.c index 79465a1..8c550d3 100644 --- a/udevd.c +++ b/udevd.c @@ -1006,6 +1006,35 @@ int main(int argc, char *argv[], char *envp[]) goto exit; } =20 + /* setup signal handler pipe */ + retval =3D pipe(signal_pipe); + if (retval < 0) { + err("error getting pipes: %s", strerror(errno)); + goto exit; + } + + retval =3D fcntl(signal_pipe[READ_END], F_GETFL, 0); + if (retval < 0) { + err("error fcntl on read pipe: %s", strerror(errno)); + goto exit; + } + retval =3D 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 =3D fcntl(signal_pipe[WRITE_END], F_GETFL, 0); + if (retval < 0) { + err("error fcntl on write pipe: %s", strerror(errno)); + goto exit; + } + retval =3D 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); } =20 - /* setup signal handler pipe */ - retval =3D pipe(signal_pipe); - if (retval < 0) { - err("error getting pipes: %s", strerror(errno)); - goto exit; - } - - retval =3D fcntl(signal_pipe[READ_END], F_GETFL, 0); - if (retval < 0) { - err("error fcntl on read pipe: %s", strerror(errno)); - goto exit; - } - retval =3D 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 =3D fcntl(signal_pipe[WRITE_END], F_GETFL, 0); - if (retval < 0) { - err("error fcntl on write pipe: %s", strerror(errno)); - goto exit; - } - retval =3D 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 =3D (void (*)(int)) sig_handler; --=20 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=3Djoin.php&p=3Dsourceforge&CID=DEVD= EV _______________________________________________ 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