#include "platform.h"
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
Go to the source code of this file.
◆ sigchld_handler()
static void sigchld_handler |
( |
int |
val | ) |
|
|
static |
Definition at line 39 of file gnunet-timeout.c.
40{
43
44 (void) val;
46 if (WIFEXITED (
status) != 0)
47 {
50 }
51 if (WIFSIGNALED (
status) != 0)
52 {
54 kill (getpid (),
ret);
55 }
56 _exit (-1);
57}
static int ret
Final status code.
static int status
The program status; 0 for success.
References child, ret, and status.
Referenced by main().
◆ sigint_handler()
static void sigint_handler |
( |
int |
val | ) |
|
|
static |
◆ main()
int main |
( |
int |
argc, |
|
|
char * |
argv[] |
|
) |
| |
Definition at line 69 of file gnunet-timeout.c.
70{
72 pid_t gpid = 0;
73
74 if (argc < 3)
75 {
76 fprintf (stderr,
77 "arg 1: timeout in sec., arg 2: executable, arg<n> arguments\n");
78 exit (-1);
79 }
80
82
85
86
87 gpid = getpgrp ();
88
96
99 {
100
101
102 if (-1 != gpid)
103 setpgid (0, gpid);
104 execvp (argv[2], &argv[2]);
105 exit (-1);
106 }
108 {
110 printf ("Child processes were killed after timeout of %u seconds\n",
112 kill (0, SIGTERM);
113 exit (3);
114 }
115 exit (-1);
116}
static struct GNUNET_TIME_Relative timeout
User defined timestamp for completing operations.
static void sigint_handler(int val)
static void sigchld_handler(int val)
References child, sigchld_handler(), sigint_handler(), and timeout.
◆ child