The tree.h and queue.h include guards must remain so users don't
accidentally get their system queue.h included as well.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Turns out O_TMPFILE can fail in interesting ways when the underlying
filesystem doesn't support unnamed inodes, e.g. Azure used by GitHub
Actions. Here's the exact qoute from open(2):
"O_TMPFILE requires support by the underlying filesystem; only a
subset of Linux filesystems provide that support. In the initial
implementation, support was provided in the ext2, ext3, ext4, UDF,
Minix, and shmem filesystems. Support for other filesystems has
subsequently been added as follows: XFS (Linux 3.15); Btrfs (Linux
3.16); F2FS (Linux 3.16); and ubifs (Linux 4.9)"
This patch adds a silent fallback to tmpfile() in these cases.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The GNU libtool numbers are just SO confusing.
- New interfaces (new functions) added/removed/changed: 7 -> 8
- Interfaces added: 2 -> 3
End result, steps 5.2.0 to 5.3.0, which makes sense.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Coverity highlighted a problem with logically dead code from the change
prior that triggered this refactor. When system() returns we may have
exited either normally or due to a signal.
My reasoning behind systemf() is to allow users to treat external calls
as any other syscall, abstracting away the WIFFOO() macros. This leaves
us with either the return value of the external program >= 0, or -1 and
errno for everything else. I.e., if fork() or alloca() fails we may get
ENOMEM and if the program doesn't catch signals properly, EINTR.
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
The call to system() may return -1, e.g. if fork() fails or return
status from execl() cannot be read. In these cases we should end
immediately and not call WIFEXITED() et al.
Also, WEXITSTATUS() should only be called if WEXITED() returns true.
For details, see system(3) and wait(2).
Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
Be consistent with errno codes from libite, we already have other APIs
that return ENOMEM if alloca() fails, so let's do the same for these
new ones as well.
Also, simplify va_start()/va_end() handling in these APIs, no point
in the extra complexity before this patch.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
If kill() is successful, and the signal was SIGKILL, we remove() the PID
file and return the rc of remove(), otherwise we always return the rc of
kill().
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
These two functions look for a string in a (terminate) list of strings
and returns the index to that string, or -1 if not found or error.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
Some systems may not yet have defined LLONG_MAX and LLONG_MIN in
limits.h, in particular older GLIBC installs are affected.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
A `const` string is a declaration to the user of an API that the
implementation does not touch the contents.
We do some `(char *)` casting in this patch, but the resulting
code still does not touch the contents of the original pointer.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>