From 00b71dd3c303dc2ce0445eb4e76bb84b76c34085 Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 24 Jul 2019 10:31:16 +0200 Subject: [PATCH 1/3] pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index e5352038..3a668e3a 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -347,22 +347,27 @@ function gitstatus_start() { --dirty-max-index-size=${(q)dirty_max_index_size} ${${log_level:#INFO}:+--log-level=$log_level}) - # We use `zsh -c` instead of plain {} or () to work around bugs in zplug. It hangs on startup. - zsh -dfxc " + local cmd=" + echo \$\$ ${(q)daemon} $daemon_args if [[ \$? != (0|10) && \$? -le 128 && -z ${(q)GITSTATUS_DAEMON:-} && -f ${(q)daemon}-static ]]; then ${(q)daemon}-static $daemon_args fi - echo -nE $'bye\x1f0\x1e' - " <$req_fifo >$resp_fifo 2>$log_file 3<$lock_file &! + echo -nE $'bye\x1f0\x1e'" + cmd="setopt monitor; zsh -dfxc ${(q)cmd} &!" + # We use `zsh -c` instead of plain {} or () to work around bugs in zplug. It hangs on startup. + # Double fork is to daemonize. Some macOS users had issues when gitstatusd was a child process + # of the interactive zsh. For example, https://github.com/romkatv/powerlevel10k/issues/123 + # and https://github.com/romkatv/powerlevel10k/issues/97. + zsh -dfxc $cmd <$req_fifo >$resp_fifo 2>$log_file 3<$lock_file &! - daemon_pid=$! - sysopen -w -o cloexec,sync -u req_fd $req_fifo sysopen -r -o cloexec -u resp_fd $resp_fifo + read -u $resp_fd daemon_pid + rm -f $req_fifo $resp_fifo $lock_file function _gitstatus_process_response_${name}() { From d572fb974683123668065c5a4a778e8e57ca864f Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 24 Jul 2019 12:11:11 +0200 Subject: [PATCH 2/3] pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 3a668e3a..615c85f6 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -356,12 +356,14 @@ function gitstatus_start() { ${(q)daemon}-static $daemon_args fi echo -nE $'bye\x1f0\x1e'" - cmd="setopt monitor; zsh -dfxc ${(q)cmd} &!" + cmd="${commands[setsid]:-} zsh -dfxc ${(q)cmd} &!" # We use `zsh -c` instead of plain {} or () to work around bugs in zplug. It hangs on startup. # Double fork is to daemonize. Some macOS users had issues when gitstatusd was a child process # of the interactive zsh. For example, https://github.com/romkatv/powerlevel10k/issues/123 - # and https://github.com/romkatv/powerlevel10k/issues/97. - zsh -dfxc $cmd <$req_fifo >$resp_fifo 2>$log_file 3<$lock_file &! + # and https://github.com/romkatv/powerlevel10k/issues/97. If you are using macOS and seeing + # errors like `gitstatus_query:echo:32: write error: broken pipe`, install `setsid` utility + # by running `brew install util-linux`. + zsh -dfmxc $cmd <$req_fifo >$resp_fifo 2>$log_file 3<$lock_file &! sysopen -w -o cloexec,sync -u req_fd $req_fifo sysopen -r -o cloexec -u resp_fd $resp_fifo From bb2f9afafea1de38196c4b5181564b6e97925fba Mon Sep 17 00:00:00 2001 From: romkatv Date: Wed, 24 Jul 2019 12:26:04 +0200 Subject: [PATCH 3/3] pull upstream changes from gitstatus --- gitstatus/gitstatus.plugin.zsh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitstatus/gitstatus.plugin.zsh b/gitstatus/gitstatus.plugin.zsh index 615c85f6..07c36f54 100644 --- a/gitstatus/gitstatus.plugin.zsh +++ b/gitstatus/gitstatus.plugin.zsh @@ -356,7 +356,9 @@ function gitstatus_start() { ${(q)daemon}-static $daemon_args fi echo -nE $'bye\x1f0\x1e'" - cmd="${commands[setsid]:-} zsh -dfxc ${(q)cmd} &!" + local setsid=${commands[setsid]:-/usr/local/opt/util-linux/bin/setsid} + [[ -f $setsid ]] && setsid=${(q)setsid} || setsid= + cmd="$setsid zsh -dfxc ${(q)cmd} &!" # We use `zsh -c` instead of plain {} or () to work around bugs in zplug. It hangs on startup. # Double fork is to daemonize. Some macOS users had issues when gitstatusd was a child process # of the interactive zsh. For example, https://github.com/romkatv/powerlevel10k/issues/123