xsecurelock  1.7.0
XSecureLock is an X11 screen lock utility.
Macros | Functions
wait_pgrp.h File Reference
#include <limits.h>
#include <unistd.h>

Go to the source code of this file.

Macros

#define WAIT_ALREADY_DEAD   INT_MIN
 
#define WAIT_NONPOSITIVE_SIGNAL   (INT_MIN + 1)
 

Functions

void InitWaitPgrp (void)
 Initializes WaitPgrp. More...
 
pid_t ForkWithoutSigHandlers (void)
 Fork a subprocess, but do not inherit our signal handlers. More...
 
void StartPgrp (void)
 Starts a new process group. More...
 
int ExecvHelper (const char *path, const char *const argv[])
 Spawns a helper process. More...
 
int KillPgrp (pid_t pid, int signo)
 Kills the given process group. More...
 
int WaitPgrp (const char *name, pid_t *pid, int do_block, int already_killed, int *exit_status)
 Waits for the given process group to terminate, or checks its status. If the leader process died, kill the entire group. More...
 
int WaitProc (const char *name, pid_t *pid, int do_block, int already_killed, int *exit_status)
 Waits for the given process to terminate, or checks its status. More...
 

Macro Definition Documentation

◆ WAIT_ALREADY_DEAD

#define WAIT_ALREADY_DEAD   INT_MIN

◆ WAIT_NONPOSITIVE_SIGNAL

#define WAIT_NONPOSITIVE_SIGNAL   (INT_MIN + 1)

Function Documentation

◆ ExecvHelper()

int ExecvHelper ( const char *  path,
const char *const  argv[] 
)

Spawns a helper process.

Works just like execv(), but if path is a relative path, it looks it up within HELPER_PATH.

If it fails, it logs a message about what it tried to execute and how it failed.

◆ ForkWithoutSigHandlers()

pid_t ForkWithoutSigHandlers ( void  )

Fork a subprocess, but do not inherit our signal handlers.

Otherwise behaves exactly like fork().

◆ InitWaitPgrp()

void InitWaitPgrp ( void  )

Initializes WaitPgrp.

Actually just installs an empty SIGCHLD handler so select(), sigsuspend() etc. get interrupted by the signal.

◆ KillPgrp()

int KillPgrp ( pid_t  pid,
int  signo 
)

Kills the given process group.

Parameters
pidThe process group ID.
signoThe signal to send to the process group.
Returns
Zero if and only if sending the signal succeeded.

◆ StartPgrp()

void StartPgrp ( void  )

Starts a new process group.

Must be called from a child process, which will become the process group leader. The process group will never die, unless killed using KillPgrp (which WaitPgrp calls implicitly when the leader process terminates).

Returns
Zero if the operation succeeded.

◆ WaitPgrp()

int WaitPgrp ( const char *  name,
pid_t *  pid,
int  do_block,
int  already_killed,
int *  exit_status 
)

Waits for the given process group to terminate, or checks its status. If the leader process died, kill the entire group.

Parameters
nameThe name of the process group for logging.
pidThe process group ID; it is set to zero if the process group died.
do_blockWhether to wait for the process group to terminate.
already_killedWhether the caller already sent SIGTERM to the process group. If so, we will not log this signal as that'd be spam.
exit_statusVariable that receives the exit status of the leader when it terminated. Will be negative for a signal, positive for a regular exit, or one of the WAIT_* constants.
Returns
True if the process group is still alive.

◆ WaitProc()

int WaitProc ( const char *  name,
pid_t *  pid,
int  do_block,
int  already_killed,
int *  exit_status 
)

Waits for the given process to terminate, or checks its status.

Parameters
nameThe name of the process for logging.
pidThe process ID; it is set to zero if the process died.
do_blockWhether to wait for the process to terminate.
already_killedWhether the caller already sent SIGTERM to the process. If so, we will not log this signal as that'd be spam.
exit_statusVariable that receives the exit status of the leader when it terminated. Will be negative for a signal, positive for a regular exit, or one of the WAIT_* constants.
Returns
True if the process is still alive.