On 9 June 2011 13:48, stateless <statel...@archlinux.us> wrote:
> Hi,
>
> Just to be on the same page and we don't start working on the same
> tools.  I'll look into implementing id, kill and comm.
>
> Thanks,
> stateless

Ah man, I've just been doing kill.c myself. Lowest SLOC count makes it
into base?
#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]);

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

	return 0;
}

Attachment: kill.1
Description: Binary data

Reply via email to