aboutsummaryrefslogtreecommitdiffstats
path: root/src/satd.c
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-28 15:13:34 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-28 15:13:34 +0100
commit911aa010edf3367555e58c6dfea55ed0eb91541c (patch)
treee23779723e5ed3bb69a4735ee0fceb2ef0dcfd7f /src/satd.c
parentupdate daemonise, and daemonise when fully initialised (diff)
downloadsat-911aa010edf3367555e58c6dfea55ed0eb91541c.tar.gz
sat-911aa010edf3367555e58c6dfea55ed0eb91541c.tar.bz2
sat-911aa010edf3367555e58c6dfea55ed0eb91541c.tar.xz
we do not need to be able to pass the file descriptor via well defined fd:s now that we can keep the socket when called daemonise
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
Diffstat (limited to '')
-rw-r--r--src/satd.c26
1 files changed, 4 insertions, 22 deletions
diff --git a/src/satd.c b/src/satd.c
index 1bfb829..df562ac 100644
--- a/src/satd.c
+++ b/src/satd.c
@@ -164,7 +164,7 @@ int
main(int argc, char *argv[])
{
struct sockaddr_un address;
- int sock = -1, foreground = 0, fd = -1, have_socket = 0;
+ int sock = -1, foreground = 0, fd = -1;
struct stat attr;
char *path;
@@ -190,22 +190,8 @@ main(int argc, char *argv[])
free(path);
}
- /* Determinate whether the socket was passed with stdin. */
- if (fstat(STDIN_FILENO, &attr))
- t (errno != EBADF);
- else if ((path = getenv("SATD_SOCKET_PATH")))
- have_socket = S_ISSOCK(attr.st_mode);
-
- /* Get or create socket. */
- if (have_socket) {
- if (strlen(path) >= sizeof(address.sun_path))
- t ((errno = ENAMETOOLONG));
- strcpy(address.sun_path, path);
- }
- if (have_socket)
- sock = STDIN_FILENO;
- else
- t (sock = create_socket(&address), sock == -1);
+ /* Create socket. */
+ t (sock = create_socket(&address), sock == -1);
/* Socket shall be on fd 3, and all below shall be /dev/null. */
if (sock != 3) {
@@ -230,11 +216,7 @@ main(int argc, char *argv[])
#endif
/* Daemonise. */
- if (!foreground) {
- int flags = have_socket ? DAEMONISE_KEEP_STDIN : 0;
- flags |= DAEMONISE_KEEP_FDS;
- t (daemonise("satd", flags, sock, -1));
- }
+ t (foreground ? 0 : daemonise("satd", DAEMONISE_KEEP_FDS, sock, -1));
close(sock);
unlink(address.sun_path);