Signed-off-by: Petr Uzel <petr.uzel@xxxxxxx> --- misc-utils/uuidd.c | 19 ++----------------- 1 files changed, 2 insertions(+), 17 deletions(-) diff --git a/misc-utils/uuidd.c b/misc-utils/uuidd.c index 4a230fb..c5c58ae 100644 --- a/misc-utils/uuidd.c +++ b/misc-utils/uuidd.c @@ -59,26 +59,11 @@ static void die(const char *msg) static void create_daemon(void) { - pid_t pid; uid_t euid; - pid = fork(); - if (pid == -1) { - perror("fork"); - exit(1); - } else if (pid != 0) { - exit(0); - } - - close(0); - close(1); - close(2); - open("/dev/null", O_RDWR); - open("/dev/null", O_RDWR); - open("/dev/null", O_RDWR); + if (daemon(0,0)) + die("daemon"); - if (chdir("/")) {} /* Silence warn_unused_result warning */ - (void) setsid(); euid = geteuid(); if (setreuid(euid, euid) < 0) die("setreuid"); -- 1.7.1 -- To unsubscribe from this list: send the line "unsubscribe util-linux" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html