Skip to content

Commit 4383d2b

Browse files
committed
Fix post installation 'hang' bug, simplify daemon start
1 parent cb5e01b commit 4383d2b

7 files changed

Lines changed: 19 additions & 41 deletions

File tree

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect\
99
bin/resh-daemon bin/resh-control bin/resh-config bin/resh-cli\
1010
bin/resh-install-utils bin/resh-generate-uuid bin/resh-get-epochtime
1111

12+
# we disable jobserver for the actual installation because we want it to run serially
13+
# Make waits to the daemon process we launch during install and hangs
1214
install: build
15+
make -j1 _install
16+
17+
_install:
1318
scripts/install.sh
1419

1520
test:
@@ -35,7 +40,6 @@ bin/resh-%: $(go_files)
3540

3641
.PHONY: submodules build install rebuild uninstall clean test
3742

38-
3943
submodules: | submodules/bash-preexec/bash-preexec.sh submodules/bash-zsh-compat-widgets/bindfunc.sh
4044
@# sets submodule.recurse to true if unset
4145
@# sets status.submoduleSummary to true if unset

scripts/hooks.sh

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ __resh_collect() {
3737
echo "RESH WARNING: You probably just updated RESH - PLEASE RESTART OR RELOAD THIS TERMINAL SESSION (resh revision: $(resh-collect -revision); resh revision of this terminal session: ${__RESH_REVISION})"
3838
fi
3939
fi
40-
# TODO: change how resh-uuid is read
4140
if [ "$__RESH_VERSION" = "$(resh-collect -version)" ] && [ "$__RESH_REVISION" = "$(resh-collect -revision)" ]; then
4241
resh-collect -requireVersion "$__RESH_VERSION" \
4342
-requireRevision "$__RESH_REVISION" \
@@ -51,9 +50,9 @@ __resh_collect() {
5150
-gitRemote "$__RESH_GIT_REMOTE" \
5251
-time "$__RESH_RT_BEFORE" \
5352
"$@"
54-
return $?
55-
fi
56-
return 1
53+
return $?
54+
fi
55+
return 1
5756
}
5857

5958
__resh_precmd() {

scripts/install.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ cp -f submodules/bash-preexec/bash-preexec.sh ~/.bash-preexec.sh
109109
cp -f submodules/bash-zsh-compat-widgets/bindfunc.sh ~/.resh/bindfunc.sh
110110

111111
cp -f scripts/shellrc.sh ~/.resh/shellrc
112+
cp -f scripts/resh-daemon-start.sh ~/.resh/bin/resh-daemon-start
112113
cp -f scripts/reshctl.sh scripts/widgets.sh scripts/hooks.sh scripts/util.sh ~/.resh/
113114
cp -f scripts/rawinstall.sh ~/.resh/
114115

@@ -126,11 +127,15 @@ if [ ! -f "$pid_file" ]; then
126127
pid_file=~/.resh/resh.pid
127128
fi
128129

130+
failed_to_kill() {
131+
echo "ERROR: Failed to kill the resh-daemon - maybe it wasn't running?"
132+
}
133+
129134
if [ -f "$pid_file" ]; then
130-
kill -SIGTERM "$pid_file"
135+
kill -SIGKILL "$pid_file" || failed_to_kill
131136
rm "$pid_file"
132137
else
133-
pkill -SIGTERM "resh-daemon"
138+
pkill -SIGKILL "resh-daemon" || failed_to_kill
134139
fi
135140

136141
echo "Creating/updating config file ..."
@@ -161,13 +166,8 @@ fi
161166
# Deleting zsh completion cache - for future use
162167
# [ ! -e ~/.zcompdump ] || rm ~/.zcompdump
163168

164-
# Source utils to get __resh_run_daemon function
165-
# shellcheck source=util.sh
166-
. ~/.resh/util.sh
167-
168169
echo "Launching resh daemon ..."
169-
__resh_run_daemon
170-
170+
~/.resh/bin/resh-daemon-start
171171

172172
info="---- Scroll down using arrow keys ----
173173
#####################################

scripts/resh-daemon-start.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
#! /usr/bin/env sh
2+
nohup resh-daemon >/dev/null 2>/dev/null & disown

scripts/reshctl.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,6 @@ __resh_unbind_control_R() {
5050
return 0
5151
}
5252

53-
__resh_bind_all() {
54-
__resh_bind_control_R
55-
}
56-
57-
__resh_unbind_all() {
58-
__resh_unbind_control_R
59-
}
60-
6153
# wrapper for resh-cli for calling resh directly
6254
resh() {
6355
local buffer

scripts/shellrc.sh

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
#!/hint/sh
22

33
PATH=$PATH:~/.resh/bin
4-
# if [ -n "$ZSH_VERSION" ]; then
5-
# zmodload zsh/datetime
6-
# fi
74

85
# shellcheck source=hooks.sh
96
. ~/.resh/hooks.sh
@@ -31,7 +28,7 @@ export __RESH_VERSION=$(resh-collect -version)
3128
# shellcheck disable=2155
3229
export __RESH_REVISION=$(resh-collect -revision)
3330

34-
__resh_run_daemon
31+
resh-daemon-start
3532

3633
[ "$(resh-config --key BindControlR)" = true ] && __resh_bind_control_R
3734

scripts/util.sh

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,6 @@
22

33
# util.sh - resh utility functions
44

5-
# FIXME: figure out if stdout/stderr should be discarded
6-
__resh_run_daemon() {
7-
if [ -n "${ZSH_VERSION-}" ]; then
8-
setopt LOCAL_OPTIONS NO_NOTIFY NO_MONITOR
9-
fi
10-
if [ "$(uname)" = Darwin ]; then
11-
# hotfix
12-
gnohup resh-daemon >/dev/null 2>/dev/null & disown
13-
else
14-
# TODO: switch to nohup for consistency once you confirm that daemon is
15-
# not getting killed anymore on macOS
16-
nohup resh-daemon >/dev/null 2>/dev/null & disown
17-
#setsid resh-daemon 2>&1 & disown
18-
fi
19-
}
20-
215
__resh_session_init() {
226
if [ "$__RESH_VERSION" != "$(resh-session-init -version)" ]; then
237
# shellcheck source=shellrc.sh

0 commit comments

Comments
 (0)