• R/O
  • SSH
  • HTTPS

yash: Commit


Commit MetaInfo

Revision4009 (tree)
Time2019-12-22 01:00:14
Authormagicant

Log Message

Optimize process forking with pipefail

When the pipe-fail option is on, the shell needs to await not only the
last command of a pipeline but also other commands. Because of this, the
optimization of not forking an unnecessary process for the last command
was not applied when the option was on.

If there is only one command in the pipeline, however, the pipe-fail
option can be ignored and the optimization is applicable.

Change Summary

Incremental Difference

--- yash/trunk/exec.c (revision 4008)
+++ yash/trunk/exec.c (revision 4009)
@@ -312,7 +312,7 @@
312312 suppresserrreturn |= suppress;
313313
314314 bool self = finally_exit && !doing_job_control_now
315- && !p->next && !p->pl_neg && !any_trap_set && !shopt_pipefail;
315+ && !p->next && !p->pl_neg && !any_trap_set;
316316 exec_commands(p->pl_commands, self ? E_SELF : E_NORMAL);
317317 if (p->pl_neg) {
318318 if (laststatus == Exit_SUCCESS)
@@ -593,6 +593,9 @@
593593 count++;
594594 assert(count > 0);
595595
596+ if (type == E_SELF && shopt_pipefail && count > 1)
597+ type = E_NORMAL;
598+
596599 job = xmallocs(sizeof *job, count, sizeof *job->j_procs);
597600 ps = job->j_procs;
598601
Show on old repository browser