kill.c (76876) | kill.c (90110) |
---|---|
1/* 2 * Copyright (c) 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95"; 43#endif 44static const char rcsid[] = | 1/* 2 * Copyright (c) 1988, 1993, 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 28 unchanged lines hidden (view full) --- 37 The Regents of the University of California. All rights reserved.\n"; 38#endif /* not lint */ 39 40#ifndef lint 41#if 0 42static char sccsid[] = "@(#)kill.c 8.4 (Berkeley) 4/28/95"; 43#endif 44static const char rcsid[] = |
45 "$FreeBSD: head/bin/kill/kill.c 76876 2001-05-20 04:52:37Z kris $"; | 45 "$FreeBSD: head/bin/kill/kill.c 90110 2002-02-02 06:48:10Z imp $"; |
46#endif /* not lint */ 47 48#include <ctype.h> 49#include <err.h> 50#include <errno.h> 51#include <signal.h> 52#include <stdio.h> 53#include <stdlib.h> 54#include <string.h> 55 | 46#endif /* not lint */ 47 48#include <ctype.h> 49#include <err.h> 50#include <errno.h> 51#include <signal.h> 52#include <stdio.h> 53#include <stdlib.h> 54#include <string.h> 55 |
56int main __P((int, char *[])); 57void nosig __P((char *)); 58void printsignals __P((FILE *)); 59int signame_to_signum __P((char *)); 60void usage __P((void)); | 56void nosig(char *); 57void printsignals(FILE *); 58int signame_to_signum(char *); 59void usage(void); |
61 62int | 60 61int |
63main(argc, argv) 64 int argc; 65 char *argv[]; | 62main(int argc, char *argv[]) |
66{ 67 int errors, numsig, pid; 68 char *ep; 69 70 if (argc < 2) 71 usage(); 72 73 numsig = SIGTERM; --- 61 unchanged lines hidden (view full) --- 135 errors = 1; 136 } 137 } 138 139 exit(errors); 140} 141 142int | 63{ 64 int errors, numsig, pid; 65 char *ep; 66 67 if (argc < 2) 68 usage(); 69 70 numsig = SIGTERM; --- 61 unchanged lines hidden (view full) --- 132 errors = 1; 133 } 134 } 135 136 exit(errors); 137} 138 139int |
143signame_to_signum(sig) 144 char *sig; | 140signame_to_signum(char *sig) |
145{ 146 int n; 147 148 if (!strncasecmp(sig, "sig", (size_t)3)) 149 sig += 3; 150 for (n = 1; n < NSIG; n++) { 151 if (!strcasecmp(sys_signame[n], sig)) 152 return (n); 153 } 154 return (-1); 155} 156 157void | 141{ 142 int n; 143 144 if (!strncasecmp(sig, "sig", (size_t)3)) 145 sig += 3; 146 for (n = 1; n < NSIG; n++) { 147 if (!strcasecmp(sys_signame[n], sig)) 148 return (n); 149 } 150 return (-1); 151} 152 153void |
158nosig(name) 159 char *name; | 154nosig(char *name) |
160{ 161 162 warnx("unknown signal %s; valid signals:", name); 163 printsignals(stderr); 164 exit(1); 165} 166 167void | 155{ 156 157 warnx("unknown signal %s; valid signals:", name); 158 printsignals(stderr); 159 exit(1); 160} 161 162void |
168printsignals(fp) 169 FILE *fp; | 163printsignals(FILE *fp) |
170{ 171 int n; 172 173 for (n = 1; n < NSIG; n++) { 174 (void)fprintf(fp, "%s", sys_signame[n]); 175 if (n == (NSIG / 2) || n == (NSIG - 1)) 176 (void)fprintf(fp, "\n"); 177 else 178 (void)fprintf(fp, " "); 179 } 180} 181 182void | 164{ 165 int n; 166 167 for (n = 1; n < NSIG; n++) { 168 (void)fprintf(fp, "%s", sys_signame[n]); 169 if (n == (NSIG / 2) || n == (NSIG - 1)) 170 (void)fprintf(fp, "\n"); 171 else 172 (void)fprintf(fp, " "); 173 } 174} 175 176void |
183usage() | 177usage(void) |
184{ 185 186 (void)fprintf(stderr, "%s\n%s\n%s\n%s\n", 187 "usage: kill [-s signal_name] pid ...", 188 " kill -l [exit_status]", 189 " kill -signal_name pid ...", 190 " kill -signal_number pid ..."); 191 exit(1); 192} | 178{ 179 180 (void)fprintf(stderr, "%s\n%s\n%s\n%s\n", 181 "usage: kill [-s signal_name] pid ...", 182 " kill -l [exit_status]", 183 " kill -signal_name pid ...", 184 " kill -signal_number pid ..."); 185 exit(1); 186} |