Kontron KTAM3874-pITX Bedienungsanleitung Seite 275

  • Herunterladen
  • Zu meinen Handbüchern hinzufügen
  • Drucken
  • Seite
    / 293
  • Inhaltsverzeichnis
  • LESEZEICHEN
  • Bewertet. / 5. Basierend auf Kundenbewertungen
Seitenansicht 274
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;
}
Seitenansicht 274
1 2 ... 270 271 272 273 274 275 276 277 278 279 280 ... 292 293

Kommentare zu diesen Handbüchern

Keine Kommentare