mirror of
https://github.com/troglobit/libuev.git
synced 2026-10-01 05:22:25 +07:00
+4
-4
@@ -82,7 +82,7 @@ static void pipe_read_cb(uev_t *w, void UNUSED(*arg), int events)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Kick watchdog */
|
||||
/* Kick watchdog */
|
||||
if (watchdog)
|
||||
uev_timer_set(watchdog, 1000, 0);
|
||||
|
||||
@@ -112,9 +112,9 @@ static void pipe_write_cb(uev_t *w, void *arg, int UNUSED(events))
|
||||
|
||||
/* Here we *must* use out, not w->fd, since we're a timer callback */
|
||||
if (write(out, msg, my->counter) < 0) {
|
||||
perror("\nFailed writing to pipe");
|
||||
return;
|
||||
}
|
||||
perror("\nFailed writing to pipe");
|
||||
return;
|
||||
}
|
||||
|
||||
// fprintf(stderr, "WRITE %.*s %d\n", my->counter, msg, my->counter);
|
||||
fprintf(stderr, "%d ", my->counter);
|
||||
|
||||
+1
-1
@@ -66,7 +66,7 @@ int main(void)
|
||||
|
||||
printf("Start of test %s", ctime(&tv.tv_sec));
|
||||
printf("Expected cron %s", ctime(&when));
|
||||
|
||||
|
||||
interval = INTERVAL;
|
||||
uev_cron_init(&ctx, &cron_watcher, cron_job, NULL, when, interval);
|
||||
|
||||
|
||||
+13
-13
@@ -63,7 +63,7 @@ static int callback(arg_t *arg, int event, void *foo)
|
||||
printf("child: segfaulting failed!\n");
|
||||
#endif
|
||||
|
||||
return 42;
|
||||
return 42;
|
||||
}
|
||||
|
||||
static void sigsegv_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
|
||||
@@ -74,27 +74,27 @@ static void sigsegv_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
|
||||
|
||||
static void sigchld_cb(uev_t *UNUSED(w), void *UNUSED(arg), int UNUSED(events))
|
||||
{
|
||||
pid_t pid = waitpid(-1, NULL, WNOHANG);
|
||||
pid_t pid = waitpid(-1, NULL, WNOHANG);
|
||||
|
||||
if (-1 != pid)
|
||||
warnx("PID %d exited, bye.", pid);
|
||||
if (-1 != pid)
|
||||
warnx("PID %d exited, bye.", pid);
|
||||
}
|
||||
|
||||
static void work_cb(uev_t *UNUSED(w), void *arg, int UNUSED(events))
|
||||
{
|
||||
int status = 0;
|
||||
pid_t pid;
|
||||
pid_t pid;
|
||||
|
||||
pid = fork();
|
||||
if (-1 == pid)
|
||||
err(1, "fork");
|
||||
pid = fork();
|
||||
if (-1 == pid)
|
||||
err(1, "fork");
|
||||
if (!pid) {
|
||||
status = callback(arg, 6137, NULL);
|
||||
exit(status);
|
||||
}
|
||||
exit(status);
|
||||
}
|
||||
|
||||
if (waitpid(pid, &status, 0) == -1)
|
||||
err(1, "waitpid");
|
||||
if (waitpid(pid, &status, 0) == -1)
|
||||
err(1, "waitpid");
|
||||
|
||||
if (WIFEXITED(status))
|
||||
printf("Child exited normally => %d\n", WEXITSTATUS(status));
|
||||
@@ -108,7 +108,7 @@ static void work_cb(uev_t *UNUSED(w), void *arg, int UNUSED(events))
|
||||
|
||||
static void exit_cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
|
||||
{
|
||||
printf("Process deadline reached, exiting!\n");
|
||||
printf("Process deadline reached, exiting!\n");
|
||||
uev_exit(w->ctx);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user