setting working dir in posix_spawn() (Re: Fix 'git log' early pager startup error case)
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Aug 26, 2010, 06:18 UTC
- Message-ID
- <20100826061815.GH9708@burratino>
- In-Reply-To
- <4C752739.3010808@redhat.com>
(+cc: austin-group-futures)
Eric Blake wrote:
> On 08/25/2010 01:00 AM, Johannes Sixt wrote:
>> Just FYI, posix_spawn() is not sufficiently capable for the demands of >> start_command(): It doesn't allow to set a new CWD for the spawned process. > > And even if posix_spawn() were capable, cygwin doesn't yet implement it.
Hmm, okay. You have access to win32api, though, right? So it should be possible to reuse code from compat/mingw.c::mingw_spawnvpe.
Do you think there would be any interest in a posix_spawn() variant that takes a dir parameter? I am imagining something like this:
int posix_spawn2(pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char *const envp[restrict], const char *dir);
or this:
int posix_spawn2(pid_t *restrict pid, const char *restrict path, const posix_spawn_file_actions_t *file_actions, const posix_spawnattr_t *restrict attrp, char *const argv[restrict], char *const envp[restrict], int dirfd);
or this:
int posix_spawn_file_actions_addchdir(posix_spawn_file_actions_t *file_actions, int dirfd);