• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision4145 (tree)
Time2020-11-06 00:39:57
Authormagicant

Log Message

Always nullify stdin in async list (#40903)

Change Summary

Incremental Difference

--- yash/trunk/NEWS (revision 4144)
+++ yash/trunk/NEWS (revision 4145)
@@ -24,6 +24,10 @@
2424 now expands to \a'b' rather than ab.
2525 = When there is no command word in a simple command, redirections
2626 are now performed in a subshell after assignments are performed.
27+ = The standard input of asynchronous commands in a non-job-control
28+ shell is now always implicitly redirected to /dev/null,
29+ regardless of whether the standard input has already been
30+ redirected.
2731 * The "command" built-in with the -v or -V option was printing
2832 the pathnames of external commands with a redundant leading slash
2933 when the current working directory is "/" or "//".
@@ -32,7 +36,7 @@
3236 * When an EXIT trap is executed in a subshell with a redirection,
3337 the redirection was incorrectly not being applied to the trap.
3438 * When job control is off, the "trap" built-in was failing to set
35- a new trap for SIGINT and SIGQUIT in an asynchronous list.
39+ a new trap for SIGINT and SIGQUIT in an asynchronous command.
3640 * When job control is off, SIGINT and SIGQUIT were not being
3741 ignored if a trap had been set for the signal the main shell
3842 process.
@@ -225,12 +229,12 @@
225229 the "do" keyword can now be separated by a semicolon.
226230 . Variables that are assigned in a simple command whose command
227231 is a function no longer persist after the function finishes.
228- . The standard input of an asynchronous list is now implicitly
232+ . The standard input of an asynchronous command is now implicitly
229233 redirected to /dev/null when job control is off. Previously,
230234 this was done when the shell was interactive in the POSIXly-
231235 correct mode.
232- . The SIGINT and SIGQUIT signals on an asynchronous list are now
233- ignored only when job control is off.
236+ . The SIGINT and SIGQUIT signals on an asynchronous command are
237+ now ignored only when job control is off.
234238 . The "bindkey", "complete", "dirs", "disown", "hash", "help",
235239 "history", "popd", "pushd", "suspend", "type", "typeset", and
236240 "ulimit" built-ins are now semi-special built-ins.
--- yash/trunk/redir.c (revision 4144)
+++ yash/trunk/redir.c (revision 4145)
@@ -117,9 +117,6 @@
117117 static void reset_shellfdmin(void);
118118
119119
120-/* True iff the standard input is redirected */
121-static bool is_stdin_redirected = false;
122-
123120 /* Set of file descriptors used by the shell.
124121 * These file descriptors cannot be used by the user. */
125122 static fd_set shellfds;
@@ -291,7 +288,6 @@
291288 struct savefd_T *next;
292289 int sf_origfd; /* original file descriptor */
293290 int sf_copyfd; /* copied file descriptor */
294- bool sf_stdin_redirected; /* original `is_stdin_redirected' */
295291 };
296292
297293 static char *expand_redir_filename(const struct wordunit_T *filename)
@@ -433,9 +429,6 @@
433429 }
434430 }
435431
436- if (r->rd_fd == STDIN_FILENO)
437- is_stdin_redirected = true;
438-
439432 r = r->next;
440433 }
441434 return true;
@@ -475,7 +468,6 @@
475468 s->next = *save;
476469 s->sf_origfd = fd;
477470 s->sf_copyfd = copyfd;
478- s->sf_stdin_redirected = is_stdin_redirected;
479471 *save = s;
480472 }
481473
@@ -898,7 +890,6 @@
898890 } else {
899891 xclose(save->sf_origfd);
900892 }
901- is_stdin_redirected = save->sf_stdin_redirected;
902893
903894 savefd_T *next = save->next;
904895 free(save);
@@ -926,21 +917,18 @@
926917 * standard input is not yet redirected. */
927918 void maybe_redirect_stdin_to_devnull(void)
928919 {
929- int fd;
930-
931- if (do_job_control || is_stdin_redirected)
920+ if (do_job_control)
932921 return;
933922
934923 if (xclose(STDIN_FILENO) < 0)
935924 return;
936925
937- fd = open("/dev/null", O_RDONLY);
926+ int fd = open("/dev/null", O_RDONLY);
938927 if (fd < 0) {
939928 //xerror(errno, Ngt("cannot redirect the standard input to /dev/null"));
940929 } else {
941930 assert(fd == STDIN_FILENO);
942931 }
943- is_stdin_redirected = true;
944932 }
945933
946934
Show on old repository browser