[BusyBox] Setting proc title
Andreas Neuhaus
andy at fasta.fh-dortmund.de
Fri Mar 16 01:39:32 UTC 2001
this is how sysvinit does it:
in main():
myname = strdup(argv[0]);
argv0 = argv[0];
maxproclen = strlen(argv[0]);
setproctitle("init [%c]",runlevel);
in setproctitle():
memset(argv0, 0, maxproclen + 1);
strncpy(argv0, buf, maxproclen);
return len;
busybox klogd also does it like this: strncpy(argv[0], dz, strlen(argv[0]));
don't you think init.c should also do it this way?
this would be the patch:
Index: init.c
===================================================================
RCS file: /var/cvs/busybox/init.c,v
retrieving revision 1.127
diff -u -r1.127 init.c
--- init.c 2001/03/16 01:14:04 1.127
+++ init.c 2001/03/16 01:35:11
@@ -184,6 +184,8 @@
static int kernelVersion = 0;
static char termType[32] = "TERM=linux";
static char console[32] = _PATH_CONSOLE;
+static char *argv0 = "";
+static int argv0len = 0;
static void delete_initAction(initAction * action);
@@ -508,6 +510,7 @@
}
cmdpath = cmd[0];
+ strncpy(argv0, cmd[0], argv0len);
/*
Interactive shells want to see a dash in argv[0]. This
@@ -938,7 +941,9 @@
}
/* Fix up argv[0] to be certain we claim to be init */
- argv[0]="init";
+ argv0 = argv[0];
+ argv0len = strlen(argv[0]);
+ strncpy(argv0, "init", argv0len);
if (argc > 1)
argv[1][0]=0;
hmm... for each askfirst inittab entry busybox will stay as an "init"
process. should it switch name before waiting for enter? will reboot always
find the right process to send the signal to?
regards,
andreas neuhaus
--
Life could be so much easier if we could just look at the source code...
.~.
/V\ Andreas Neuhaus, FaStA Informatik FH-Dortmund
// \\ Sonnenstr. 96, D-44139 Dortmund, Tel 0231/9112-734
/( )\ System-Administration FaStA FH-Dortmund
^^-^^
LINUX - Don't fear the penguin
More information about the busybox
mailing list