This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [RFC/PATCH glibc 0/2] setting working dir in posix_spawn()


On 09/08/2018 12:54 AM, Eric Blake wrote:
Also, I've realized that we do NOT need posix_spawn_file_actions_addopenat(). The main benefit of openat() is that you can redirect relative file names according to an fd of your choice, without affecting global state. But during posix_spawn(), there are no other threads competing for global state (if you are doing a library implementation where the chdir() is done between fork() and exec()), so:

openat(mydir, "file", mode);

can be decomposed to:

posix_spawn_file_actions_addopen(&act, 5, ".", O_RDONLY|O_DIRECTORY, 0);
posix_spawn_file_actions_addfchdir(&act, mydir);
posix_spawn_file_actions_addopen(&act, 4, "file", mode, 0);
posix_spawn_file_actions_addfchdir(&act, 5);
posix_spawn_file_actions_addclose(&act, 5);

Is it possible to choose an appropriate value for the directory descriptor automatically?

What about support for AT_EMPTY_PATH, for upgrading an O_PATH descriptor? I think this operation still needs openat.

Thanks,
Florian


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]