* Makefile.in (kill.exe): Add as a specific target.
* kill.cc (longopts): New. (opts): Ditto. (get_sig): Accept const char * parameter. Return -1 on unknown signal. (test_for_unknown_sig): New function. (listsig): New function. (main): Use getopt_long for option parsing. Implement -l, and -s options. Use test_for_unknown_sig() to test for signal validity.
This commit is contained in:
parent
d52265ffb2
commit
c49fa76263
@ -1,3 +1,14 @@
|
|||||||
|
2002-05-13 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* Makefile.in (kill.exe): Add as a specific target.
|
||||||
|
* kill.cc (longopts): New.
|
||||||
|
(opts): Ditto.
|
||||||
|
(get_sig): Accept const char * parameter. Return -1 on unknown signal.
|
||||||
|
(test_for_unknown_sig): New function.
|
||||||
|
(listsig): New function.
|
||||||
|
(main): Use getopt_long for option parsing. Implement -l, and -s
|
||||||
|
options. Use test_for_unknown_sig() to test for signal validity.
|
||||||
|
|
||||||
2002-05-12 Christopher Faylor <cgf@redhat.com>
|
2002-05-12 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* mount.cc (do_mount): Default to non-exec option for remote drives.
|
* mount.cc (do_mount): Default to non-exec option for remote drives.
|
||||||
|
@ -111,7 +111,6 @@ else
|
|||||||
${filter-out -nostdinc,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(DUMPER_INCLUDES) $<
|
${filter-out -nostdinc,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(DUMPER_INCLUDES) $<
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
module_info.o: module_info.cc
|
module_info.o: module_info.cc
|
||||||
ifdef VERBOSE
|
ifdef VERBOSE
|
||||||
${filter-out -nostdinc,$(COMPILE_CXX)} $c -o $@ $(DUMPER_INCLUDES) ${firstword $^}
|
${filter-out -nostdinc,$(COMPILE_CXX)} $c -o $@ $(DUMPER_INCLUDES) ${firstword $^}
|
||||||
@ -168,6 +167,14 @@ else
|
|||||||
${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
|
${filter-out -I$(newlib_source)/%,$(COMPILE_CXX)} $c -o $(@D)/$(basename $@)$o $(MINGW_CXXFLAGS) $<
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
kill.exe: kill.o $(bupdir1)/libiberty/strsignal.o
|
||||||
|
ifdef VERBOSE
|
||||||
|
$(CXX) -o $@ $^ -B$(cygwin_build)/ $(ALL_LDFLAGS) $(KILL_LIB)
|
||||||
|
else
|
||||||
|
@echo $(CXX) -o $@ $^ ${filter-out -B%, $(ALL_LDFLAGS)};\
|
||||||
|
$(CXX) -o $@ $^ -B$(cygwin_build)/ $(ALL_LDFLAGS) $(KILL_LIB)
|
||||||
|
endif
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *.o $(CLEAN_PROGS)
|
rm -f *.o $(CLEAN_PROGS)
|
||||||
|
|
||||||
|
@ -16,6 +16,20 @@ details. */
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <sys/cygwin.h>
|
#include <sys/cygwin.h>
|
||||||
|
#include <getopt.h>
|
||||||
|
|
||||||
|
static struct option longopts[] =
|
||||||
|
{
|
||||||
|
{"help", no_argument, NULL, 'h' },
|
||||||
|
{"list", optional_argument, NULL, 'l'},
|
||||||
|
{"force", no_argument, NULL, 'f'},
|
||||||
|
{"signal", required_argument, NULL, 's'},
|
||||||
|
{NULL, 0, NULL, 0}
|
||||||
|
};
|
||||||
|
|
||||||
|
static char opts[] = "hl::fs:";
|
||||||
|
|
||||||
|
extern "C" const char *strsigno (int);
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage (void)
|
usage (void)
|
||||||
@ -25,10 +39,11 @@ usage (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
getsig (char *in_sig)
|
getsig (const char *in_sig)
|
||||||
{
|
{
|
||||||
char *sig;
|
const char *sig;
|
||||||
char buf[80];
|
char buf[80];
|
||||||
|
int intsig;
|
||||||
|
|
||||||
if (strncmp (in_sig, "SIG", 3) == 0)
|
if (strncmp (in_sig, "SIG", 3) == 0)
|
||||||
sig = in_sig;
|
sig = in_sig;
|
||||||
@ -37,7 +52,37 @@ getsig (char *in_sig)
|
|||||||
sprintf (buf, "SIG%s", in_sig);
|
sprintf (buf, "SIG%s", in_sig);
|
||||||
sig = buf;
|
sig = buf;
|
||||||
}
|
}
|
||||||
return (strtosigno (sig) ?: atoi (in_sig));
|
intsig = strtosigno (sig) ?: atoi (in_sig);
|
||||||
|
char *p;
|
||||||
|
if (!intsig && (strcmp (buf, "SIG0") != 0 && (strtol (in_sig, &p, 10) != 0 || *p)))
|
||||||
|
intsig = -1;
|
||||||
|
return intsig;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
test_for_unknown_sig (int sig, const char *sigstr)
|
||||||
|
{
|
||||||
|
if (sig < 0 || sig > NSIG)
|
||||||
|
{
|
||||||
|
fprintf (stderr, "kill: unknown signal: %s\n", sigstr);
|
||||||
|
usage ();
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
listsig (const char *in_sig)
|
||||||
|
{
|
||||||
|
int sig;
|
||||||
|
if (!in_sig)
|
||||||
|
for (sig = 1; sig < NSIG; sig++)
|
||||||
|
printf ("%s%c", strsigno (sig) + 3, (sig < NSIG - 1) ? ' ' : '\n');
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sig = getsig (in_sig);
|
||||||
|
test_for_unknown_sig (sig, in_sig);
|
||||||
|
puts (strsigno (sig) + 3);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __stdcall
|
static void __stdcall
|
||||||
@ -59,36 +104,59 @@ main (int argc, char **argv)
|
|||||||
{
|
{
|
||||||
int sig = SIGTERM;
|
int sig = SIGTERM;
|
||||||
int force = 0;
|
int force = 0;
|
||||||
int gotsig = 0;
|
char *gotsig = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
usage ();
|
usage ();
|
||||||
|
|
||||||
while (*++argv && **argv == '-')
|
opterr = 0;
|
||||||
if (strcmp (*argv + 1, "f") == 0)
|
for (;;)
|
||||||
force = 1;
|
{
|
||||||
else if (gotsig)
|
int ch;
|
||||||
|
char **av = argv + optind;
|
||||||
|
if ((ch = getopt_long (argc, argv, opts, longopts, NULL)) == EOF)
|
||||||
break;
|
break;
|
||||||
else if (strcmp(*argv + 1, "0") != 0)
|
switch (ch)
|
||||||
{
|
{
|
||||||
sig = getsig (*argv + 1);
|
case 's':
|
||||||
gotsig = 1;
|
gotsig = optarg;
|
||||||
|
sig = getsig (gotsig);
|
||||||
|
break;
|
||||||
|
case 'l':
|
||||||
|
if (!optarg)
|
||||||
|
{
|
||||||
|
optarg = argv[optind];
|
||||||
|
if (optarg)
|
||||||
|
{
|
||||||
|
optind++;
|
||||||
|
optreset = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (argv[optind])
|
||||||
|
usage ();
|
||||||
|
listsig (optarg);
|
||||||
|
break;
|
||||||
|
case 'f':
|
||||||
|
force = 1;
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
if (gotsig)
|
||||||
|
usage ();
|
||||||
|
optreset = 1;
|
||||||
|
optind = 1 + av - argv;
|
||||||
|
gotsig = *av + 1;
|
||||||
|
sig = getsig (gotsig);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
usage ();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
argv++;
|
|
||||||
sig = 0;
|
|
||||||
goto sig0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sig <= 0 || sig > NSIG)
|
test_for_unknown_sig (sig, gotsig);
|
||||||
{
|
|
||||||
fprintf (stderr, "kill: unknown signal: %s\n", argv[-1]);
|
|
||||||
exit (1);
|
|
||||||
}
|
|
||||||
|
|
||||||
sig0:
|
argv += optind;
|
||||||
while (*argv != NULL)
|
while (*argv != NULL)
|
||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -109,7 +109,7 @@ do_mount (const char *dev, const char *where, int flags)
|
|||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct option longopts[] =
|
static struct option longopts[] =
|
||||||
{
|
{
|
||||||
{"help", no_argument, NULL, 'h' },
|
{"help", no_argument, NULL, 'h' },
|
||||||
{"binary", no_argument, NULL, 'b'},
|
{"binary", no_argument, NULL, 'b'},
|
||||||
@ -127,7 +127,7 @@ struct option longopts[] =
|
|||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
|
|
||||||
char opts[] = "hbfstuxXEpicm";
|
static char opts[] = "hbfstuxXEpicm";
|
||||||
|
|
||||||
static void
|
static void
|
||||||
usage (void)
|
usage (void)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user