libite 2.6.1
|
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include <unistd.h>
Go to the source code of this file.
Functions | |
char * | chomp (char *str) |
pid_t | pidfile_read (const char *pidfile) |
pid_t | pidfile_poll (const char *pidfile) |
int | pidfile_signal (const char *pidfile, int signal) |
|
extern |
Perl like chomp function, chop off last char(s) if newline.
str | String to chomp |
This function is like Perl chomp, but it's set to chop of all trailing newlines. Useful in combination with fgets().
NULL
with errno set, if str is not a valid pointer. EINVAL | if the input argument is not a valid pointer. |
pid_t pidfile_poll | ( | const char * | pidfile | ) |
Poll for the existence of a pidfile and return PID.
pidfile | Path to pidfile to poll for |
This function polls for the pidfile at pidfile
for at most 5 seconds before timing out. If the file is created within that time span the file is read and its PID contents returned.
pidfile
, or zero on timeout. Definition at line 89 of file pidfilefn.c.
pid_t pidfile_read | ( | const char * | pidfile | ) |
Reads a PID value from a pidfile.
pidfile | File containing PID, usually in /var/run/PROCNAME .pid |
This function takes a pidfile
and returns the PID found therein.
pidfile
, -1 with errno set. If the pidfile
is empty, or when its contents cannot be translated, this function returns zero (0), on success this function returns a PID value greater than one.EINVAL | on invalid pidfile , or |
ENOENT | when pidfile does not exist. |
Definition at line 49 of file pidfilefn.c.
int pidfile_signal | ( | const char * | pidfile, |
int | signal ) |
Send signal to a PID and cleanup pidfile afterwards.
pidfile | File containing PID, usually in /var/run/PROCNAME .pid |
signal | Signal to send to PID found in pidfile . |
If signal
is any of SIGTERM
or SIGKILL
, or if kill(2) returns -1, the pidfile
is removed.
Definition at line 114 of file pidfilefn.c.