/* Busyboxed by Denys Vlasenko <vda.linux@googlemail.com> */
/* TODO: depends on runit_lib.c - review and reduce/eliminate */
-#include <sys/poll.h>
+//usage:#define runsvdir_trivial_usage
+//usage: "[-P] [-s SCRIPT] DIR"
+//usage:#define runsvdir_full_usage "\n\n"
+//usage: "Start a runsv process for each subdirectory. If it exits, restart it.\n"
+//usage: "\n -P Put each runsv in a new session"
+//usage: "\n -s SCRIPT Run SCRIPT <signo> after signal is processed"
+
#include <sys/file.h>
#include "libbb.h"
#include "runit_lib.h"
struct pollfd pfd[1];
unsigned stamplog;
#endif
-};
+} FIX_ALIASING;
#define G (*(struct globals*)&bb_common_bufsiz1)
#define sv (G.sv )
#define svdir (G.svdir )
#define logpipe (G.logpipe )
#define pfd (G.pfd )
#define stamplog (G.stamplog )
-#define INIT_G() do { \
-} while (0)
+#define INIT_G() do { } while (0)
static void fatal2_cannot(const char *m1, const char *m2)
{
}
run:
#endif
- curdir = open_read(".");
+ curdir = open(".", O_RDONLY|O_NDELAY);
if (curdir == -1)
fatal2_cannot("open current directory", "");
close_on_exec_on(curdir);
last_mtime = s.st_mtime;
last_dev = s.st_dev;
last_ino = s.st_ino;
- //if (now <= mtime)
- // sleep(1);
+ /* if the svdir changed this very second, wait until the
+ * next second, because we won't be able to detect more
+ * changes within this second */
+ while (time(NULL) == last_mtime)
+ usleep(100000);
need_rescan = do_rescan();
while (fchdir(curdir) == -1) {
warn2_cannot("change directory, pausing", "");