More stuff

This commit is contained in:
Eric Andersen 1999-10-23 05:42:08 +00:00
parent a07f0b0408
commit a709317cea
6 changed files with 77 additions and 61 deletions

View File

@ -2,6 +2,10 @@
* usage() now printf the BusyBox version. This will help folks * usage() now printf the BusyBox version. This will help folks
realize that they are not in Kansas anymore. realize that they are not in Kansas anymore.
* Fixed mkdir -m option so that it works. * Fixed mkdir -m option so that it works.
* kill segfaulted w/o any arguments. Now it doesn't do that.
* kill wasn't properly accepting signal names. It does now.
-Erik Andersen
0.31 0.31
* I added a changelog for version 0.30. * I added a changelog for version 0.30.
@ -16,6 +20,7 @@
it wasn't supported before GNU libc 2.1, and some folks use it wasn't supported before GNU libc 2.1, and some folks use
glibc 2.0.7 since it is much smaller than that latest and greatest. glibc 2.0.7 since it is much smaller than that latest and greatest.
-Erik Andersen
0.30 0.30
Major changes -- lots of stuff rewritten. Many thanks to Lineo for Major changes -- lots of stuff rewritten. Many thanks to Lineo for

View File

@ -22,7 +22,11 @@ BUILDTIME=$(shell date "+%Y%m%d-%H%M")
# Comment out the following to make a debuggable build # Comment out the following to make a debuggable build
# Leave this off for production use. # Leave this off for production use.
#DODEBUG=true DODEBUG=false
# If you want a static binary, turn this on. I can't think
# of many situations where anybody would ever want it static,
# but...
DOSTATIC=false
#This will choke on a non-debian system #This will choke on a non-debian system
ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'` ARCH=`uname -m | sed -e 's/i.86/i386/' | sed -e 's/sparc.*/sparc/'`
@ -37,6 +41,11 @@ else
CFLAGS=-Wall -Os -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE CFLAGS=-Wall -Os -fomit-frame-pointer -fno-builtin -D_GNU_SOURCE
LDFLAGS= -s LDFLAGS= -s
STRIP= strip --remove-section=.note --remove-section=.comment $(PROG) STRIP= strip --remove-section=.note --remove-section=.comment $(PROG)
#Only staticly link when _not_ debugging
ifeq ($(DOSTATIC),true)
LDFLAGS+= --static
endif
endif endif
ifndef $(prefix) ifndef $(prefix)

View File

@ -11,11 +11,11 @@ Source: busybox-0.29a1.tar.gz
%Description %Description
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
provides a pretty complete environment that fits on a floppy or in a provides a pretty complete POSIX environment in a very small package.
ROM. Just add "ash" (Keith Almquists tiny Bourne shell clone) and "ae", Just add a kernel, "ash" (Keith Almquists tiny Bourne shell clone), and
and a kernel and you have a full system. This is used on the Debian an editor such as "elvis-tiny" or "ae", and you have a full system. This
install disk and in an internet router, and it makes a good environment is makes an excellent environment for a "rescue" disk or any small or
for a "rescue" disk or any small or embedded system. embedded system.
%Prep %Prep
%setup -q -n busybox %setup -q -n busybox

View File

@ -11,11 +11,11 @@ Source: busybox-0.29a1.tar.gz
%Description %Description
BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It BusyBox is a suite of "tiny" Unix utilities in a multi-call binary. It
provides a pretty complete environment that fits on a floppy or in a provides a pretty complete POSIX environment in a very small package.
ROM. Just add "ash" (Keith Almquists tiny Bourne shell clone) and "ae", Just add a kernel, "ash" (Keith Almquists tiny Bourne shell clone), and
and a kernel and you have a full system. This is used on the Debian an editor such as "elvis-tiny" or "ae", and you have a full system. This
install disk and in an internet router, and it makes a good environment is makes an excellent environment for a "rescue" disk or any small or
for a "rescue" disk or any small or embedded system. embedded system.
%Prep %Prep
%setup -q -n busybox %setup -q -n busybox

51
kill.c
View File

@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <ctype.h>
const char kill_usage[] = "kill [-signal] process-id [process-id ...]\n"; const char kill_usage[] = "kill [-signal] process-id [process-id ...]\n";
@ -112,47 +113,47 @@ const struct signal_name signames[] = {
extern int kill_main (int argc, char **argv) extern int kill_main (int argc, char **argv)
{ {
int had_error = 0;
int sig = SIGTERM; int sig = SIGTERM;
if ( argc < 2 )
usage (kill_usage);
if ( **(argv+1) == '-' ) {
if (argv[1][0] == '-') { if (isdigit( *(*(++argv)+1) )) {
if (argv[1][1] >= '0' && argv[1][1] <= '9') { sig = atoi (*argv);
sig = atoi (&argv[1][1]);
if (sig < 0 || sig >= NSIG) if (sig < 0 || sig >= NSIG)
goto end; goto end;
} else { }
else {
const struct signal_name *s = signames; const struct signal_name *s = signames;
for (;;) { while (s->name != 0) {
if (strcmp (s->name, &argv[1][1]) == 0) { if (strcasecmp (s->name, *argv+1) == 0) {
sig = s->number; sig = s->number;
break; break;
} }
s++; s++;
if (s->name == 0)
goto end;
} }
if (s->name == 0)
goto end;
} }
argv++; }
argc--;
} while (--argc > 1) {
while (argc > 1) {
int pid; int pid;
if (argv[1][0] < '0' || argv[1][0] > '9') if (! isdigit( **(++argv))) {
goto end; fprintf(stderr, "bad PID: %s\n", *argv);
pid = atoi (argv[1]); exit( FALSE);
if (kill (pid, sig) != 0) { }
had_error = 1; pid = atoi (*argv);
perror (argv[1]); if (kill (pid, sig) != 0) {
perror (*argv);
exit ( FALSE);
} }
argv++;
argc--;
} }
if (had_error) {
end: end:
usage (kill_usage); fprintf(stderr, "bad signal name: %s\n", *argv);
}
exit (TRUE); exit (TRUE);
} }

View File

@ -25,6 +25,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <ctype.h>
const char kill_usage[] = "kill [-signal] process-id [process-id ...]\n"; const char kill_usage[] = "kill [-signal] process-id [process-id ...]\n";
@ -112,47 +113,47 @@ const struct signal_name signames[] = {
extern int kill_main (int argc, char **argv) extern int kill_main (int argc, char **argv)
{ {
int had_error = 0;
int sig = SIGTERM; int sig = SIGTERM;
if ( argc < 2 )
usage (kill_usage);
if ( **(argv+1) == '-' ) {
if (argv[1][0] == '-') { if (isdigit( *(*(++argv)+1) )) {
if (argv[1][1] >= '0' && argv[1][1] <= '9') { sig = atoi (*argv);
sig = atoi (&argv[1][1]);
if (sig < 0 || sig >= NSIG) if (sig < 0 || sig >= NSIG)
goto end; goto end;
} else { }
else {
const struct signal_name *s = signames; const struct signal_name *s = signames;
for (;;) { while (s->name != 0) {
if (strcmp (s->name, &argv[1][1]) == 0) { if (strcasecmp (s->name, *argv+1) == 0) {
sig = s->number; sig = s->number;
break; break;
} }
s++; s++;
if (s->name == 0)
goto end;
} }
if (s->name == 0)
goto end;
} }
argv++; }
argc--;
} while (--argc > 1) {
while (argc > 1) {
int pid; int pid;
if (argv[1][0] < '0' || argv[1][0] > '9') if (! isdigit( **(++argv))) {
goto end; fprintf(stderr, "bad PID: %s\n", *argv);
pid = atoi (argv[1]); exit( FALSE);
if (kill (pid, sig) != 0) { }
had_error = 1; pid = atoi (*argv);
perror (argv[1]); if (kill (pid, sig) != 0) {
perror (*argv);
exit ( FALSE);
} }
argv++;
argc--;
} }
if (had_error) {
end: end:
usage (kill_usage); fprintf(stderr, "bad signal name: %s\n", *argv);
}
exit (TRUE); exit (TRUE);
} }