poser
A C framework for POsix SERvices
Loading...
Searching...
No Matches
PSC_RunOpts Class Reference

Options for running a service. More...

#include <poser/core/runopts.h>

Static Public Member Functions

void PSC_RunOpts_init (const char *pidfile)
 Initialize to default values.
 
void PSC_RunOpts_runas (long uid, long gid)
 Run as a different user.
 
void PSC_RunOpts_enableDefaultLogging (const char *logident)
 Handle logging using default options.
 
void PSC_RunOpts_foreground (void)
 Run in foreground.
 
void PSC_RunOpts_nowait (void)
 Don't wait for successful service startup.
 

Detailed Description

Options for running a service.

These options are used by PSC_Service and PSC_Daemon.

Member Function Documentation

◆ PSC_RunOpts_enableDefaultLogging()

void PSC_RunOpts_enableDefaultLogging ( const char *  logident)
static

Handle logging using default options.

This will automatically configure logging during service startup.

When running daemonized (default), it will log to syslog as well as stderr and stop logging to stderr as soon as the service startup completed. It will also enable asynchronous logging after successful startup.

When running in foreground, it will just configure logging to stderr.

Parameters
logidentname to use for syslog logging (default: posercore)

◆ PSC_RunOpts_foreground()

void PSC_RunOpts_foreground ( void  )
static

Run in foreground.

When this is set, PSC_Daemon_run() will directly call the daemon main function without forking or handling a pidfile.

◆ PSC_RunOpts_init()

void PSC_RunOpts_init ( const char *  pidfile)
static

Initialize to default values.

Resets all run options to their default values. If this isn't explicitly called, options are automatically initialized without a pidfile.

Parameters
pidfilethe pidfile to use, or NULL for none

◆ PSC_RunOpts_nowait()

void PSC_RunOpts_nowait ( void  )
static

Don't wait for successful service startup.

When this is set, the parent process will exit immediately instead of waiting for PSC_Daemon_launched() to be called.

◆ PSC_RunOpts_runas()

void PSC_RunOpts_runas ( long  uid,
long  gid 
)
static

Run as a different user.

When a different user is set here, an attempt is made to switch to it during service startup. This will only work when the service was launched by the superuser (root).

Parameters
uiduser-id to switch to, or -1 for no change
gidgroup-id to switch to, or -1 for no change

The documentation for this class was generated from the following file: