Teonet library  0.4.7
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pidfile.c File Reference
#include "config/config.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include "pidfile.h"
#include "utils/utils.h"

Macros

#define GET_PIDFILE_DIR()   ksnet_formatMessage("%s/", ksnet_getDataDir())
 
#define PIDFILE_EX   "pid"
 
#define PIDFILE_NAME_LEN   128
 
#define EXE_NAME   "ksnet"
 

Functions

void init_pidfile (int port)
 Create the pid file name. More...
 
void kill_pidfile ()
 Free the pid file name. More...
 
int _write_pidfile (char *pidfilename)
 Write current pid to the specified pidfile. More...
 
int write_pidfile ()
 Write current pid to the all pidfiles. More...
 
int _read_pidfile (char *pidfilename)
 Read current pid from the specified pidfile. More...
 
void read_pidfile (int *port_pid)
 Read current pid from the all pidfiles. More...
 
int check_pid (int pid)
 Search for process with pid. More...
 
void remove_pidfile ()
 Remove the pid files. More...
 

Detailed Description

License:
TEONET is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

TEONET is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.

Macro Definition Documentation

#define EXE_NAME   "ksnet"

Referenced by init_pidfile().

#define GET_PIDFILE_DIR ( )    ksnet_formatMessage("%s/", ksnet_getDataDir())

Referenced by init_pidfile().

#define PIDFILE_EX   "pid"

Referenced by init_pidfile().

#define PIDFILE_NAME_LEN   128

Referenced by init_pidfile().

Function Documentation

int _read_pidfile ( char *  pidfilename)

Read current pid from the specified pidfile.

Parameters
pidfilenamePid file name
Returns

Referenced by read_pidfile().

int _write_pidfile ( char *  pidfilename)

Write current pid to the specified pidfile.

Parameters
pidfilenamePid file name
Returns

Referenced by write_pidfile().

int check_pid ( int  pid)

Search for process with pid.

Parameters
pid
Returns

References FALSE, and TRUE.

Referenced by start_stop_daemon().

void init_pidfile ( int  port)

Create the pid file name.

Parameters
portPort number

References EXE_NAME, free(), GET_PIDFILE_DIR, malloc(), PIDFILE_EX, and PIDFILE_NAME_LEN.

Referenced by start_stop_daemon().

void kill_pidfile ( )

Free the pid file name.

References free().

Referenced by start_stop_daemon().

void read_pidfile ( int *  port_pid)

Read current pid from the all pidfiles.

Parameters
port_pid

References _read_pidfile().

Referenced by start_stop_daemon().

void remove_pidfile ( )

Remove the pid files.

Referenced by start_stop_daemon().

int write_pidfile ( )

Write current pid to the all pidfiles.

Returns

References _write_pidfile(), and result.

Referenced by start_stop_daemon().