From 0cc9b20c15460213e488bf5e70963b941482f628 Mon Sep 17 00:00:00 2001 From: William Harrington Date: Tue, 14 Jan 2025 16:06:02 -0600 Subject: Add source. --- sdk/proc/process.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 sdk/proc/process.h (limited to 'sdk/proc/process.h') diff --git a/sdk/proc/process.h b/sdk/proc/process.h new file mode 100644 index 0000000..d65b765 --- /dev/null +++ b/sdk/proc/process.h @@ -0,0 +1,57 @@ +/* + * Portable process handling routines. + * $Id$ + * Copyright (c) 1997 by Tycho Softworks. + * For conditions of distribution and reuse see product license. + */ + +#ifndef __PROC_PROCESS_H__ +#define __PROC_PROCESS_H__ + +#ifndef __STD_PROCESS_H__ +#include +#endif + +/* Spawn services under UNIX fork() */ + +#define P_NOWAIT 0x00 /* Default, run concurrent */ +#define P_WAIT 0x01 /* Wait for and return exit status */ +#define P_BACKGROUND 0x02 /* Detach child from our stdio */ +#define P_SESSION 0x04 /* Use setsid() on child */ +#define P_OVERLAY 0x08 /* Really 'exec' called via spawn */ + +/* Some common/portable spawn varients and masks */ + +#define P_DETACH P_NOWAIT | P_SESSION | P_BACKGROUND +#define P_NOWAITO P_NOWAIT | P_SESSION + +/* Daemon initialization options */ + +#define D_KEEPSTDIO 0 /* Daemon keeps stdio connection */ +#define D_KEEPALL 1 /* Daemon keeps all open files */ +#define D_KEEPNONIO 2 /* Detach from stdio, keep others open */ +#define D_KEEPNONE 3 /* Deamon closes all files */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Common process invokation services using fork() */ + +#ifdef __NAMESPACE +#define spawnv __NAMESPACE(spawnv) +#define spawnvp __NAMESPACE(spawnvp) +#define pdetach __NAMESPACE(pdetach) +#define priority __NAMEPSACE(priority) +#endif + +int spawnv(const int P_mode, const char *path, char *const argv[]); +int spawnvp(const int P_mode, const char *path, char *const argv[]); +pid_t pdetach(const int D_flag); /* Make current process a daemon */ +int priority(int pri); /* set realtime priorities */ + +#ifdef __cplusplus +} +#endif + +#endif -- cgit v1.2.3-54-g00ecf