From 2c99851181a652358aa3ca58ef38c57e46ae02e4 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Wed, 12 Apr 2006 18:09:26 +0000 Subject: - patch from Denis Vlasenko to add and use bb_xdaemon() --- libbb/Makefile.in | 2 +- libbb/bb_xdaemon.c | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) create mode 100644 libbb/bb_xdaemon.c (limited to 'libbb') diff --git a/libbb/Makefile.in b/libbb/Makefile.in index c69978370..3fb945e31 100644 --- a/libbb/Makefile.in +++ b/libbb/Makefile.in @@ -30,7 +30,7 @@ LIBBB-y:= \ trim.c u_signal_names.c vdprintf.c verror_msg.c \ vherror_msg.c vperror_msg.c wfopen.c xconnect.c xgetcwd.c xstat.c \ xgethostbyname.c xgethostbyname2.c xreadlink.c xregcomp.c xgetlarg.c \ - bb_xsocket.c \ + bb_xsocket.c bb_xdaemon.c \ get_terminal_width_height.c fclose_nonstdin.c fflush_stdout_and_exit.c \ getopt_ulflags.c default_error_retval.c wfopen_input.c speed_table.c \ perror_nomsg_and_die.c perror_nomsg.c skip_whitespace.c bb_askpass.c \ diff --git a/libbb/bb_xdaemon.c b/libbb/bb_xdaemon.c new file mode 100644 index 000000000..a40f4f993 --- /dev/null +++ b/libbb/bb_xdaemon.c @@ -0,0 +1,17 @@ +/* vi: set sw=4 ts=4: */ +/* + * bb_xdaemon.c - a daemon() which dies on failure with error message + * + * Copyright (C) 2006 Denis Vlasenko + * + * Licensed under LGPL, see file docs/lesser.txt in this tarball for details. + */ +#include +#include "libbb.h" + +void bb_xdaemon(int nochdir, int noclose) +{ + if (daemon(nochdir, noclose)) + bb_perror_msg_and_die("daemon"); +} + -- cgit v1.2.3