pgrep,pkill: new applets by Loic Grenie <loic.grenie@gmail.com>
This commit is contained in:
		@@ -58,33 +58,29 @@ int kill_main(int argc, char **argv)
 | 
			
		||||
	if (arg[1] == 'l' && arg[2] == '\0') {
 | 
			
		||||
		if (argc == 1) {
 | 
			
		||||
			/* Print the whole signal list */
 | 
			
		||||
			for (signo = 1; signo < 32; signo++) {
 | 
			
		||||
				const char *name = get_signame(signo);
 | 
			
		||||
				if (!isdigit(name[0]))
 | 
			
		||||
					puts(name);
 | 
			
		||||
			}
 | 
			
		||||
		} else { /* -l <sig list> */
 | 
			
		||||
			while ((arg = *++argv)) {
 | 
			
		||||
				if (isdigit(arg[0])) {
 | 
			
		||||
					signo = bb_strtou(arg, NULL, 10);
 | 
			
		||||
					if (errno) {
 | 
			
		||||
						bb_error_msg("unknown signal '%s'", arg);
 | 
			
		||||
						return EXIT_FAILURE;
 | 
			
		||||
					}
 | 
			
		||||
					/* Exitcodes >= 0x80 are to be treated
 | 
			
		||||
					 * as "killed by signal (exitcode & 0x7f)" */
 | 
			
		||||
					puts(get_signame(signo & 0x7f));
 | 
			
		||||
					/* TODO: 'bad' signal# - coreutils says:
 | 
			
		||||
					 * kill: 127: invalid signal
 | 
			
		||||
					 * we just print "127" instead */
 | 
			
		||||
				} else {
 | 
			
		||||
					signo = get_signum(arg);
 | 
			
		||||
					if (signo < 0) {
 | 
			
		||||
						bb_error_msg("unknown signal '%s'", arg);
 | 
			
		||||
						return EXIT_FAILURE;
 | 
			
		||||
					}
 | 
			
		||||
					printf("%d\n", signo);
 | 
			
		||||
			print_signames_and_exit();
 | 
			
		||||
		}
 | 
			
		||||
		/* -l <sig list> */
 | 
			
		||||
		while ((arg = *++argv)) {
 | 
			
		||||
			if (isdigit(arg[0])) {
 | 
			
		||||
				signo = bb_strtou(arg, NULL, 10);
 | 
			
		||||
				if (errno) {
 | 
			
		||||
					bb_error_msg("unknown signal '%s'", arg);
 | 
			
		||||
					return EXIT_FAILURE;
 | 
			
		||||
				}
 | 
			
		||||
				/* Exitcodes >= 0x80 are to be treated
 | 
			
		||||
				 * as "killed by signal (exitcode & 0x7f)" */
 | 
			
		||||
				puts(get_signame(signo & 0x7f));
 | 
			
		||||
				/* TODO: 'bad' signal# - coreutils says:
 | 
			
		||||
				 * kill: 127: invalid signal
 | 
			
		||||
				 * we just print "127" instead */
 | 
			
		||||
			} else {
 | 
			
		||||
				signo = get_signum(arg);
 | 
			
		||||
				if (signo < 0) {
 | 
			
		||||
					bb_error_msg("unknown signal '%s'", arg);
 | 
			
		||||
					return EXIT_FAILURE;
 | 
			
		||||
				}
 | 
			
		||||
				printf("%d\n", signo);
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		/* If they specified -l, we are all done */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user