On 9 June 2011 13:54, stateless <statel...@archlinux.us> wrote:
> Arrgh fucking gmail.

+1
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <signal.h>
#include "util.h"

int
main(int argc, char *argv[])
{
	int sig = SIGTERM;
	char c, *end;

	while((c = getopt(argc, argv, "s:")) != -1)
		switch(c){
		case 's':
			sig = strtol(optarg, &end, 0);
			if(*end != '\0')
				eprintf("%s: not a (signal) number\n", optarg);
			break;
		default:
			eprintf("usage: %s [-s signal] [pid...]\n", argv[0]);
		}

	if(optind == argc)
		eprintf("%s: not enough arguments\n", argv[0]);

	for(; optind < argc; optind++) {
		int pid = strtol(argv[optind], &end, 0);

		if(*end != '\0')
			eprintf("%s: not a number\n", argv[optind]);

		if(kill(pid, sig) == -1)
			eprintf("kill %d:", pid);
	}

	return 0;
}

Reply via email to