version 1.29, 2010/03/23 16:16:09 |
version 1.30, 2010/04/01 05:05:19 |
|
|
static char * |
static char * |
next_field(char *str) |
next_field(char *str) |
{ |
{ |
if ((str = strchr(str, ' ')) == NULL) |
char *spaces = " \t"; |
|
size_t span; |
|
|
|
span = strcspn(str, spaces); |
|
if (span == strlen(str)) |
return (NULL); |
return (NULL); |
|
|
*str = '\0'; |
str += span; |
while (*++str == ' ') /* loop */ |
*str++ = '\0'; |
; |
|
|
|
/* if there is nothing left of the string, return NULL */ |
while (strcspn(str, spaces) == 0) |
/* This fix is dedicated to Greg Earle */ |
str++; |
return (*str == '\0' ? NULL : str); |
|
|
if (*str == '\0') |
|
return (NULL); |
|
|
|
return(str); |
} |
} |
|
|
/* |
/* |
|
|
int signum = SIGTERM, procnum; |
int signum = SIGTERM, procnum; |
uid_t uid, puid; |
uid_t uid, puid; |
char tempbuf[TEMPBUFSIZE]; |
char tempbuf[TEMPBUFSIZE]; |
char *nptr; |
char *nptr, *tmp; |
|
|
|
tmp = tempbuf; |
|
|
/* reset error array */ |
/* reset error array */ |
ERR_RESET; |
ERR_RESET; |
|
|
|
|
while (isspace(*str)) |
while (isspace(*str)) |
str++; |
str++; |
|
|
if (str[0] == '-') { |
if (*str == '-') { |
|
str++; |
|
|
/* explicit signal specified */ |
/* explicit signal specified */ |
if ((nptr = next_field(str)) == NULL) |
if ((nptr = next_field(str)) == NULL) |
return (" kill: no processes specified"); |
return (" kill: no processes specified"); |
|
|
if (isdigit(str[1])) { |
if (isdigit(*str)) { |
(void) scan_arg(str + 1, &signum, nptr); |
(void) scan_arg(str, &signum, tmp); |
if (signum <= 0 || signum >= NSIG) |
if (signum <= 0 || signum >= NSIG) |
return (" invalid signal number"); |
return (" invalid signal number"); |
} else { |
} else { |
/* translate the name into a number */ |
/* translate the name into a number */ |
for (signum = 0; signum < NSIG; signum++) { |
for (signum = 0; signum < NSIG; signum++) { |
if (strcasecmp(sys_signame[signum], str + 1) == 0) |
if (strcasecmp(sys_signame[signum], |
|
str) == 0) |
break; |
break; |
} |
} |
|
|