linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] udevd: Init signal pipe before forking to background
@ 2007-01-21 20:28 Sergey Vlasov
  2007-01-21 21:53 ` Kay Sievers
  0 siblings, 1 reply; 2+ messages in thread
From: Sergey Vlasov @ 2007-01-21 20:28 UTC (permalink / raw)
  To: linux-hotplug

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 <vsu@altlinux.ru>
---
 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;
 	}
 
+	/* 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;
-- 
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
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

* Re: [PATCH] udevd: Init signal pipe before forking to background
  2007-01-21 20:28 [PATCH] udevd: Init signal pipe before forking to background Sergey Vlasov
@ 2007-01-21 21:53 ` Kay Sievers
  0 siblings, 0 replies; 2+ messages in thread
From: Kay Sievers @ 2007-01-21 21:53 UTC (permalink / raw)
  To: linux-hotplug

On 1/21/07, Sergey Vlasov <vsu@altlinux.ru> wrote:
> 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
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

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

end of thread, other threads:[~2007-01-21 21:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-21 20:28 [PATCH] udevd: Init signal pipe before forking to background Sergey Vlasov
2007-01-21 21:53 ` Kay Sievers

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).