124 fprintf (stderr, "Usage: %s [-s signal] seconds program [args]\n\n",
126 fprintf (stderr, "You can use a numerical signal, or one of these:\n");
130 for (i = 0; sigs[i].name; i++) {
132 fprintf (stderr, "\n\t");
134 fprintf (stderr, "%s", sigs[i].name);
136 if ((i + 1) % COLS != 0)
137 fprintf (stderr, "\t");
140 fprintf (stderr, "\n\n");
149 int whatsig = SIGTERM;
156 while ((i = getopt (argc, argv, "s:")) != -1) {
159 if (isdigit (*optarg)) {
160 whatsig = atoi (optarg);
162 for (i = 0; sigs[i].name; i++) {
163 if (!strcmp (sigs[i].name, optarg)) {
164 whatsig = sigs[i].num;
171 "%s: Unknown signal %s\n",
186 if (optind > argc - 2) {
191 if (!isdigit (*argv[optind])) {
192 fprintf (stderr, "%s: \"seconds\" must be numeric, not %s\n",
201 fprintf (stderr, "%s: fork failed: ", *av);
204 } else if (pid == 0) {
205 int seconds = atoi (argv[optind]);
213 while (seconds-- > 0) {
215 * too bad there's no SIGPARENT so we have to keep
216 * polling to find out if it's still there
219 if (kill (pid, 0) != 0)
228 execvp (argv[optind + 1], argv + optind + 1);
230 fprintf (stderr, "%s: can't execute ", *av);
231 perror (argv[optind + 1]);