#include <netdb.h>
#include <mLib/alloc.h>
+#include <mLib/daemonize.h>
#include <mLib/darray.h>
#include <mLib/dstr.h>
#include <mLib/mdwopt.h>
#include <mLib/selbuf.h>
#include <mLib/sig.h>
#include <mLib/str.h>
+#include <mLib/versioncmp.h>
#include "util.h"
} else if (strcmp(q, "INFO") == 0) {
checkfg();
puts(p);
+ fflush(stdout);
} else if (strcmp(q, "OK") == 0) {
checkfg();
exit(0);
} else if (strcmp(q, "BGINFO") == 0) {
checkbg(&p);
puts(p);
+ fflush(stdout);
} else if (strcmp(q, "BGFAIL") == 0) {
checkbg(&p);
die(EXIT_FAILURE, "%s", p);
exit(0);
}
puts(p);
+ fflush(stdout);
}
static void uline(char *p, size_t len, void *b)
}
}
-static void sighup(int sig, void *v)
-{
- logfile(logname);
-}
+static void sighup(int sig, void *v) { logfile(logname); }
static void cleanup(void)
{
}
static void version(FILE *fp)
-{
- pquis(fp, "$, TrIPE version " VERSION "\n");
-}
+ { pquis(fp, "$, TrIPE version " VERSION "\n"); }
static void usage(FILE *fp)
{
if ((p = getenv("TRIPEDIR")) != 0)
dir = p;
+ if ((p = getenv("TRIPESOCK")) != 0)
+ sock = p;
/* --- Parse the arguments --- */
fclose(pidfp);
closelog();
if (f & f_daemon)
- u_detach();
+ detachtty();
execvp(DA(&spawnopts)[0], DA(&spawnopts));
die(127, "couldn't exec `%s': %s", spawnpath, strerror(errno));
}
}
if (f & f_daemon) {
- if (u_daemon())
+ if (daemonize())
die(EXIT_FAILURE, "error becoming daemon: %s", strerror(errno));
}
if (pidfp) {
if (optind < argc) {
dstr d = DSTR_INIT;
setup((f & f_warn) ? "WATCH -A+w" : "WATCH -A");
- dstr_puts(&d, argv[optind++]);
- while (optind < argc) {
- dstr_putc(&d, ' ');
- dstr_puts(&d, argv[optind++]);
- }
+ while (optind < argc)
+ u_quotify(&d, argv[optind++]);
dstr_putc(&d, '\n');
errno = EIO;
if (write(fd, d.buf, d.len) != d.len || shutdown(fd, 1))