diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-28 20:59:39 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2025-10-28 20:59:39 +0000 |
| commit | 06b4450e97ee44a08e3fb61ed3eeac035cd35c0e (patch) | |
| tree | ef11706e5e80ff548d00e5431b504d250d46ec73 /src/libenvexec | |
| parent | 5f847dc38419acdbb80daae0e58aa00d90cc6300 (diff) | |
| download | skalibs-06b4450e97ee44a08e3fb61ed3eeac035cd35c0e.tar.gz | |
Add envexec.h, reorganize headers and some sources (gol.h wasn't included in skalibs.h)
Diffstat (limited to 'src/libenvexec')
| -rw-r--r-- | src/libenvexec/prog.c | 7 | ||||
| -rw-r--r-- | src/libenvexec/prog_pid_fill.c | 15 | ||||
| -rw-r--r-- | src/libenvexec/strerr_diev.c | 13 | ||||
| -rw-r--r-- | src/libenvexec/strerr_dievsys.c | 13 | ||||
| -rw-r--r-- | src/libenvexec/strerr_warnv.c | 17 | ||||
| -rw-r--r-- | src/libenvexec/strerr_warnvsys.c | 20 |
6 files changed, 85 insertions, 0 deletions
diff --git a/src/libenvexec/prog.c b/src/libenvexec/prog.c new file mode 100644 index 0000000..3c5f7f5 --- /dev/null +++ b/src/libenvexec/prog.c @@ -0,0 +1,7 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <skalibs/strerr.h> + +char const *PROG = "(none)" ; diff --git a/src/libenvexec/prog_pid_fill.c b/src/libenvexec/prog_pid_fill.c new file mode 100644 index 0000000..cec63b8 --- /dev/null +++ b/src/libenvexec/prog_pid_fill.c @@ -0,0 +1,15 @@ +/* ISC license. */ + +#include <string.h> +#include <unistd.h> + +#include <skalibs/types.h> +#include <skalibs/prog.h> + +void prog_pid_fill (char *s, char const *name, size_t len) +{ + memcpy(s, name, len) ; s += len ; + memcpy(s, ": pid ", 6) ; s += 6 ; + s += pid_fmt(s, getpid()) ; + *s++ = 0 ; +} diff --git a/src/libenvexec/strerr_diev.c b/src/libenvexec/strerr_diev.c new file mode 100644 index 0000000..bf1e8fc --- /dev/null +++ b/src/libenvexec/strerr_diev.c @@ -0,0 +1,13 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <unistd.h> + +#include <skalibs/strerr.h> + +void strerr_diev (int e, char const *const *v, unsigned int n) +{ + strerr_warnv(v, n) ; + _exit(e) ; +} diff --git a/src/libenvexec/strerr_dievsys.c b/src/libenvexec/strerr_dievsys.c new file mode 100644 index 0000000..10437f9 --- /dev/null +++ b/src/libenvexec/strerr_dievsys.c @@ -0,0 +1,13 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <unistd.h> + +#include <skalibs/strerr.h> + +void strerr_dievsys (int e, char const *const *v, unsigned int n) +{ + strerr_warnvsys(v, n) ; + _exit(e) ; +} diff --git a/src/libenvexec/strerr_warnv.c b/src/libenvexec/strerr_warnv.c new file mode 100644 index 0000000..f59cfe9 --- /dev/null +++ b/src/libenvexec/strerr_warnv.c @@ -0,0 +1,17 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <errno.h> + +#include <skalibs/buffer.h> +#include <skalibs/strerr.h> + +void strerr_warnv (char const *const *v, unsigned int n) +{ + int e = errno ; + for (unsigned int i = 0 ; i < n ; i++) + if (v[i]) buffer_puts(buffer_2, v[i]) ; + buffer_putflush(buffer_2, "\n", 1) ; + errno = e ; +} diff --git a/src/libenvexec/strerr_warnvsys.c b/src/libenvexec/strerr_warnvsys.c new file mode 100644 index 0000000..fcab1b8 --- /dev/null +++ b/src/libenvexec/strerr_warnvsys.c @@ -0,0 +1,20 @@ +/* ISC license. */ + +/* MT-unsafe */ + +#include <string.h> +#include <errno.h> + +#include <skalibs/buffer.h> +#include <skalibs/strerr.h> + +void strerr_warnvsys (char const *const *v, unsigned int n) +{ + int e = errno ; + for (unsigned int i = 0 ; i < n ; i++) + if (v[i]) buffer_puts(buffer_2, v[i]) ; + buffer_put(buffer_2, ": ", 2) ; + buffer_puts(buffer_2, strerror(e)) ; + buffer_putflush(buffer_2, "\n", 1) ; + errno = e ; +} |
