Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[fix] Fix premature exit detection
  • Loading branch information
mmalecki committed Sep 3, 2013
1 parent e1ce78d commit 198970a
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/aeternum.c
Expand Up @@ -78,10 +78,6 @@ void spawn_child(int detach) {
options.exit_cb = detach ? NULL : spawn_cb;
if (detach) options.flags = UV_PROCESS_DETACHED;

if (opts.min_uptime != 0) {
gettimeofday(&start_tv, NULL);
}

if (uv_spawn(loop, &child_req, options)) {
fprintf(stderr, "Error %s\n", uv_err_name(uv_last_error(loop)));
fprintf(stderr, "%s\n", uv_strerror(uv_last_error(loop)));
Expand All @@ -103,8 +99,8 @@ void spawn_cb(uv_process_t *req, int exit_status, int signal_status) {

if (opts.min_uptime != 0) {
gettimeofday(&tv, NULL);
ms_up = ((start_tv.tv_sec * 1000) + (start_tv.tv_usec / 1000)) -
((tv.tv_sec * 1000) + (tv.tv_usec / 1000));
ms_up = ((tv.tv_sec * 1000) + (tv.tv_usec / 1000)) -
((start_tv.tv_sec * 1000) + (start_tv.tv_usec / 1000));

if (ms_up < opts.min_uptime) {
fprintf(stderr, "Child exited prematurely with %d, exiting.\n", exit_status);
Expand Down Expand Up @@ -229,6 +225,8 @@ int main(int argc, char *argv[]) {
min_uptime = saneopt_get(opt, "min-uptime");
if (min_uptime != NULL) {
sscanf(min_uptime, "%d", &opts.min_uptime);
gettimeofday(&start_tv, NULL);

}
else {
opts.min_uptime = 0;
Expand Down

0 comments on commit 198970a

Please sign in to comment.