diff options
author | sin <sin@2f30.org> | 2014-02-06 11:27:32 +0000 |
---|---|---|
committer | sin <sin@2f30.org> | 2014-02-06 11:31:34 +0000 |
commit | fd0f19b55727f4cc005bfa2c7959134e4a682617 (patch) | |
tree | 1612940a6e3a02d6c830f0ea58b83379d1ff5b6a /sinit.c | |
parent | 51664faebcc10b53a1a78cff95f0efc04a2c7f8e (diff) |
Be less harsh and don't error out entirely
Diffstat (limited to 'sinit.c')
-rw-r--r-- | sinit.c | 28 |
1 files changed, 14 insertions, 14 deletions
@@ -58,19 +58,21 @@ main(void) unlink(fifopath); umask(0); if (mkfifo(fifopath, 0600) < 0) - eprintf("mkfifo %s:"); + weprintf("sinit: mkfifo %s:"); fd = open(fifopath, O_RDWR | O_NONBLOCK); if (fd < 0) - eprintf("open %s:", fifopath); - while (1) { - FD_ZERO(&rfds); - FD_SET(fd, &rfds); - n = select(fd + 1, &rfds, NULL, NULL, NULL); - if (n < 0) - eprintf("select:"); - if (FD_ISSET(fd, &rfds)) - dispatchcmd(fd); + weprintf("sinit: open %s:", fifopath); + if (fd >= 0) { + while (1) { + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + n = select(fd + 1, &rfds, NULL, NULL, NULL); + if (n < 0) + eprintf("sinit: select:"); + if (FD_ISSET(fd, &rfds)) + dispatchcmd(fd); + } } return EXIT_SUCCESS; @@ -97,9 +99,7 @@ dispatchcmd(int fd) n = read(fd, buf, sizeof(buf) - 1); if (n < 0) - eprintf("read:"); - if (n == 0) - return; + weprintf("sinit: read:"); buf[n] = '\0'; p = strchr(buf, '\n'); if (p) @@ -119,7 +119,7 @@ spawn(const char *file, char *const argv[]) pid = fork(); if (pid < 0) - eprintf("fork:"); + weprintf("sinit: fork:"); if (pid == 0) { setsid(); setpgid(0, 0); |