From 2f2a221c569d514a5796984e9d58219c8b03ee11 Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Sun, 4 Mar 2018 21:54:12 -0600 Subject: [PATCH] Don't spawn keepalive for WSL when only one command This should speed things up on slower PCs given that the vast majority of shell commands are simple jobs consisting of a single command without any pipelines, in which case there's no need for a keepalive process at all. Applies to WSL only. --- src/exec.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/exec.cpp b/src/exec.cpp index 1dced989c..ecf2ffa29 100644 --- a/src/exec.cpp +++ b/src/exec.cpp @@ -577,15 +577,17 @@ void exec_job(parser_t &parser, job_t *j) { needs_keepalive = true; break; } + // When running under WSL, create a keepalive process unconditionally if our first process is external. + // This is because WSL does not permit joining the pgrp of an exited process. + // (see https://github.com/Microsoft/WSL/issues/2786), also fish PR #4676 + if (is_windows_subsystem_for_linux() && j->processes.front()->type == EXTERNAL + && !p->is_first_in_job) { //but not if it's the only process + needs_keepalive = true; + break; + } } } - // When running under WSL, create a keepalive process unconditionally if our first process is external. - // This is because WSL does not permit joining the pgrp of an exited process. - // (see https://github.com/Microsoft/WSL/issues/2786), also fish PR #4676 - if (j->processes.front()->type == EXTERNAL && is_windows_subsystem_for_linux()) - needs_keepalive = true; - if (needs_keepalive) { // Call fork. No need to wait for threads since our use is confined and simple. pid_t parent_pid = getpid();