Ktam3874/pitx software guide, After the input of, Sudo rcconf – Kontron KTAM3874-pITX User Manual
Page 275: You see the following screen

KTD-S0057-I
Page 271 Linux® Programming Examples (DebianTM)
KTAM3874/pITX Software Guide
After the input of
sudo rcconf
you see the following screen
The next item concerns the pidfile topic. The presence of a locked pidfile prevents two instances of a
daemon with the same name from running at the same time. The pidfile contains a single line of text, being
the numeric process ID of the process that currently holds the lock. The following suggestion for the server
application:
static int pidfile;
int create_pidfile (void)
{
char str [32];
if ((pidfile = open ("/var/run/serverd.pid", O_RDWR | O_CREAT)) < 0)
return
-1;
/* Try to lock the file and test the presence of an existing pidfile */
if (lockf (pidfile, F_TLOCK, 0) < 0)
{
close
(pidfile);
return
-1;
}
sprintf (str, "%d\n", getpid ());
if (write (pidfile, str, strlen (str)) < 0)
{
close
(pidfile);
return
-1;
}
return
0;
}