diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-06-15 21:03:51 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-06-15 21:03:51 -0700 |
commit | 5376b586a03b83a65f4cd40e7d982c9b8019c90a (patch) | |
tree | 83a267966a447e7fa2c6e428ee9addc2801478c3 /arith.c | |
parent | ca118fac3a97a6cd6b9342d301b3b06c515ad5f1 (diff) | |
download | txr-5376b586a03b83a65f4cd40e7d982c9b8019c90a.tar.gz txr-5376b586a03b83a65f4cd40e7d982c9b8019c90a.tar.bz2 txr-5376b586a03b83a65f4cd40e7d982c9b8019c90a.zip |
subprocesses: move fds_swizzle to child process.
In all cases in which we control fork and exec, we should be
doing the fds_swizzle setup in the child process. This has
several benefits. We do not disturb the file descriptor layout
of the parent. We don't have to set up a catch to do the
cleanup. We don't have to do the clean-up in the child either;
but just let it terminate.
* stream.c (struct save_fds): New members subin, subout and
suberr to hold the substitute file descriptors. The reason for
this is so that we can calculate these in the parent process
so that all the error checking is done in the parent and and
carry them over to the child somehow. This structure is the
natural place for that.
(fds_getfd): New static function: just does the job of
fetching and validating the file descriptor from the given
stream: the first part of fds_subst. This will be done in the
parent.
(fds_subst): Now just does the substitution using a given file
descriptor. Done in the child. Some variable renaming here; a
better name for fd_orig is fd_sub, the substitute descriptor.
(fds_prepare): New function: called in the parent process,
it obtains the three file descriptors from the streams.
(fds_swizzle): Just do fd_subst with the ready-made file
descriptors, not dealing with the streams. Called in the
child.
(open_command): Add fds_prepare call that is now needed.
(open_subprocess, run): Get rid of catch frame. Just call
fds_prepare where fds_swizzle was previously called, and only
call fds_swizzle in the child process.
Diffstat (limited to 'arith.c')
0 files changed, 0 insertions, 0 deletions