[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
execute, spawn-pipe: Allow caller to specify directory for the subproces
From: |
Bruno Haible |
Subject: |
execute, spawn-pipe: Allow caller to specify directory for the subprocess |
Date: |
Wed, 02 Dec 2020 18:12:28 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-193-generic; KDE/5.18.0; x86_64; ; ) |
It has been noted [1] that when spawning a child process, it is useful to be
able to specify in which directory to execute this child process.
The "obvious" solution, to do a chdir() before spawning the child process
and chdir() or fchdir() back afterwards, has two drawbacks:
- It is not multithread-safe.
- It interferes with the search of the program in $PATH, if $PATH contains
non-absolute directories (which is a bad practice for security reasons
but not forbidden).
This patch adds a 'directory' parameter to the functions 'execute' and
create_pipe_*.
I need this, in particular, in order to complete the Ruby support for
GNU gettext.
Note the added NEWS entries:
Date Modules Changes
2020-12-02 spawn-pipe The functions 'create_pipe_out', 'create_pipe_in',
'create_pipe_bidi' now take a 4th argument
'const char *directory'. To maintain the previous
behaviour, insert NULL as additional 4th argument.
2020-12-02 execute The function 'execute' now takes a 4th argument
'const char *directory'. To maintain the previous
behaviour, insert NULL as additional 4th argument.
[1] https://www.austingroupbugs.net/view.php?id=1208
2020-12-02 Bruno Haible <bruno@clisp.org>
spawn-pipe: Allow caller to specify directory for the subprocess.
* lib/spawn-pipe.h (create_pipe_out, create_pipe_in, create_pipe_bidi):
Add directory argument.
* lib/spawn-pipe.c: Include canonicalize.h, filename.h, findprog.h.
(create_pipe): Add directory argument. If specified, resolve the program
file name and make it absolute, first. Pass the directory to spawnpvech
and posix_spawn_file_actions_addchdir.
(create_pipe_bidi, create_pipe_in, create_pipe_out): Add directory
argument.
* modules/spawn-pipe (Depends-on): Add canonicalize, filename,
findprog-in, posix_spawn, posix_spawn_file_actions_addchdir.
* tests/test-spawn-pipe-main.c (test_pipe): Update.
* NEWS: Mention the change.
* lib/csharpcomp.c (compile_csharp_using_mono,
compile_csharp_using_sscli): Update.
* lib/javacomp.c (is_envjavac_gcj, is_envjavac_gcj43, is_gcj_present,
is_gcj_43): Update.
* lib/javaversion.c (execute_and_read_line): Update.
* lib/pipe-filter-gi.c (pipe_filter_gi_create): Update.
* lib/pipe-filter-ii.c (pipe_filter_ii_execute): Update.
2020-12-02 Bruno Haible <bruno@clisp.org>
execute: Allow caller to specify directory for the subprocess.
* lib/execute.h (execute): Add directory argument.
* lib/execute.c: Include canonicalize.h, filename.h, findprog.h.
(execute): Add directory argument. If specified, resolve the program
file name and make it absolute, first. Pass the directory to spawnpvech
and posix_spawn_file_actions_addchdir.
* modules/execute (Depends-on): Add canonicalize, filename, findprog-in,
posix_spawn, posix_spawn_file_actions_addchdir.
* tests/test-execute-main.c: Add test for passing a directory.
* tests/test-execute-child.c: Likewise.
* tests/test-execute.sh: Update.
* modules/execute-tests (Depends-on): Add mkdir.
* NEWS: Mention the change.
* lib/csharpcomp.c (compile_csharp_using_sscli): Update.
* lib/csharpexec.c (execute_csharp_using_mono,
execute_csharp_using_sscli): Update.
* lib/javacomp.c (compile_using_envjavac, compile_using_gcj,
compile_using_javac, compile_using_jikes, is_javac_present,
is_jikes_present): Update.
* lib/javaexec.c (execute_java_class): Update.
0001-execute-Allow-caller-to-specify-directory-for-the-su.patch
Description: Text Data
0002-spawn-pipe-Allow-caller-to-specify-directory-for-the.patch
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- execute, spawn-pipe: Allow caller to specify directory for the subprocess,
Bruno Haible <=