[BusyBox] Re: busybox-cvs Digest, Vol 29, Issue 4
Vladimir N. Oleynik
dzo at simtreas.ru
Tue Aug 2 09:39:23 MDT 2005
Rainer,
> What actually is unecessary is that each and every program contains a
> virtually identical sequence of code to turn it into a background
> process, especially given that there is at least one program that
> always runs in the background, namely, init, and which already
> contains everything required to be a 'supervisor' process. For special
> tasks that should run in the background, a tool can be used to just
> start them that way (please note that the code below needs
> POSIXLY_CORRECT=1 in the environment, to work around serious GNU
> getopt braindamage, and that it contains some features that are specific
> to the enviroment it usually operates in).
>
> -------------------------------
> /*
> run a program in a background session
> */
Its strange applet and haven`t 'supervisor' features:
fork()+exec*() only, and have not wait and restart if damage.
> /* functions */
> static int sys_die(char const *fnc, char const *sysc) __attribute__ ((noreturn));
>
> static int sys_die(char const *fnc, char const *sysc)
> {
> syslog(LOG_ERR, "%s: %s: %m(%d)", fnc, sysc, errno);
> exit(1);
> }
Hmm. This compiled without warning: return for not returned function?
> static void remove_lock_params(void)
> {
> char **e_run, **e_last;
>
> e_last = e_run = environ;
> if (!*e_last) return;
> while (e_last[1]) ++e_last;
>
> e_run = environ;
> while (e_run < e_last)
> if (strncmp(*e_run, LOCK_PREFIX, LOCK_PREFIX_LEN) == 0) {
> *e_run = *e_last;
> *e_last-- = NULL;
> } else
> ++e_run;
>
> if (strncmp(*e_run, LOCK_PREFIX, LOCK_PREFIX_LEN) == 0) *e_run = NULL;
> }
Hmm. Knotty.
May be simply (not tested):
static void remove_lock_params(void)
{
char **e, **t;
for (e = t = environ; t && *t; t++)
if (strncmp(*t, LOCK_PREFIX, LOCK_PREFIX_LEN) != 0) {
*e = *t;
e++;
}
if(e)
*e = NULL;
}
--w
vodz
More information about the busybox
mailing list