Ktam3874/pitx software guide – Kontron KTAM3874-pITX User Manual
Page 273

KTD-S0057-I
Page 269 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
if (!strncasecmp (buff_rd, CMD_GPIO, CMD_SIZE))
{
if (!parse_gpio (buff_rd, &value))
{
if (value != -1)
{
sprintf
(buff_wr,
DATA_STR,
value);
write
(fifo_wr,
buff_wr,
strlen
(buff_wr));
}
else
write
(fifo_wr,
ACK_STR,
ACK_SIZE);
}
else
write
(fifo_wr,
NAK_STR,
NAK_SIZE);
}
if (!strncasecmp (buff_rd, CMD_EXIT, CMD_SIZE))
break;
memset (buff_rd, 0, RD_SIZE);
}
close
(fifo_rd);
unlink
(root_rd);
close
(fifo_wr);
unlink
(root_wr);
umask (get_mask (0));
return
0;
}
Remark: it will probably be necessary to change the file permissions of the daemon program and the init
script below with
chmod
.
Some subtleties, for example the closing or redirection (/dev/null) of the standard I/O devices stdin,
stdout and stderr, are not really important and a brief explanation of pidfile usage follows later.
A good idea for the target path of the daemon would be the directory
/usr/sbin/
. Open a terminal window
and type
sudo start-stop-daemon --start --exec /usr/sbin/serverd
and then close the terminal window (ignore the 'process kill warning').
Before you close the window you can check the activity of the daemon with
pgrep -lf serverd
For terminating the daemon open again a terminal window and input the line
sudo start-stop-daemon --stop --exec /usr/sbin/serverd
or as an equivalent solution use the '
exit
' command from the client program (see page 266/267 command
table).
What do you have to do in order to integrate the daemon into the boot process? The first step consists in
the preparation of an init script named '
serv
', for example: