aboutsummaryrefslogtreecommitdiff
path: root/support/subprocess.h
diff options
context:
space:
mode:
authorSiddhesh Poyarekar <siddhesh@sourceware.org>2021-04-09 20:55:45 +0530
committerSiddhesh Poyarekar <siddhesh@sourceware.org>2021-04-14 10:37:23 +0530
commitc511c9bd051b6a2b58d02707bbc4694156fc9656 (patch)
tree0ab7de0bb3dcb37f26916c119691ca952752964b /support/subprocess.h
parent778b8d37865a1d6689155c23802724bf11e4bc75 (diff)
downloadglibc-c511c9bd051b6a2b58d02707bbc4694156fc9656.zip
glibc-c511c9bd051b6a2b58d02707bbc4694156fc9656.tar.gz
glibc-c511c9bd051b6a2b58d02707bbc4694156fc9656.tar.bz2
support: Add capability to fork an sgid child
Add a new function support_capture_subprogram_self_sgid that spawns an sgid child of the running program with its own image and returns the exit code of the child process. This functionality is used by at least three tests in the testsuite at the moment, so it makes sense to consolidate. There is also a new function support_subprogram_wait which should provide simple system() like functionality that does not set up file actions. This is useful in cases where only the return code of the spawned subprocess is interesting. This patch also ports tst-secure-getenv to this new function. A subsequent patch will port other tests. This also brings an important change to tst-secure-getenv behaviour. Now instead of succeeding, the test fails as UNSUPPORTED if it is unable to spawn a setgid child, which is how it should have been in the first place. Reviewed-by: Carlos O'Donell <carlos@redhat.com> (cherry picked from commit 716a3bdc41b2b4b864dc64475015ba51e35e1273)
Diffstat (limited to 'support/subprocess.h')
-rw-r--r--support/subprocess.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/support/subprocess.h b/support/subprocess.h
index 8b442fd..34ffd02 100644
--- a/support/subprocess.h
+++ b/support/subprocess.h
@@ -38,6 +38,11 @@ struct support_subprocess support_subprocess
struct support_subprocess support_subprogram
(const char *file, char *const argv[]);
+/* Invoke program FILE with ARGV arguments by using posix_spawn and wait for it
+ to complete. Return program exit status. */
+int support_subprogram_wait
+ (const char *file, char *const argv[]);
+
/* Wait for the subprocess indicated by PROC::PID. Return the status
indicate by waitpid call. */
int support_process_wait (struct support_subprocess *proc);