Installation manual
5. 8. Laptop-Net 35
Nowwegotothe rc.d directories and create the newsymlinks by hand.
Creating the new startup/shutdown symlinks (example):
#> cd /etc/laptop−net/profiles
#> mkdir −p work/rc.d home/rc.d xxx−default/rc.d
#> cd work/rc.d
#> ln −s ../../../init.d/ssh S20ssh
#> ln −s ../../../init.d/ssh K20ssh
Nowwehav e aproblem with ifd, the daemon which watches the status of our ethernet adapter.There seems to
exist a race between the daemon itself and the termination of the link-change shell script, which is forked by this
daemon. The offending lines are in the source file ifd.c, more precisely in the subroutine execute:
src/ifd.c:
static int
execute (const char * msg, const char * cmd)
{
int ret;
FILE * f;
char line [256];
const char * suffix = " 2>&1";
unsigned int limit = ((sizeof (line)) − ((strlen (suffix)) + 1));
syslog (LOG_INFO, "executing: ’%s’", cmd);
strncpy (line, cmd, limit);
(line[limit]) = ’\0’;
strcat (line, suffix);
f=(popen (line, "r"));
while (fgets (line, 255, f))
{
(line [(strlen (line)) − 1]) = ’\0’;
syslog (LOG_INFO, "+ %s", line);
}
ret = (pclose (f));
if (WIFEXITED (ret))
{
if (WEXITSTATUS (ret))
syslog (LOG_INFO, "%s exited with status %d",
msg, (WEXITSTATUS (ret)));
return (WEXITSTATUS (ret));
}
else
{
syslog (LOG_INFO, "%s exited on signal %d",
msg, (WTERMSIG (ret)));
return (−1);
}
}
The while loop ends as soon as fgets encounters an EOF condition. But since we are connected to stdout of the
forked shell process, this means that the shell process is terminating at this point. By the time pclose is called it
has terminated, so that pclose essentially waits on a no longer existing process, i.e. forever. The dead shell be-
comes a zombie process and ifd remains stalled until killed.
In order to fix this problem, we have hack the source code of ifd and replace the subroutine execute by:
src/ifd.c:
static int
execute (const char * msg, const char * cmd)
{
syslog (LOG_INFO, "executing: ’%s’", cmd);
return system(cmd);
}