Skip to content

Commit 10e0c7f

Browse files
committed
openbsd.rc: work around rc_bg bug when /bin/sh is bash
1 parent 6555fba commit 10e0c7f

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-1
lines changed
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
When /bin/sh is bash, this code doesn't work right - bash has a "tail call"
2+
optimization where the last command in a finite script will be run as if with
3+
exec instead of forking a new shell. rc here expects `pkill -P $$` (kill all
4+
processes with parent pid == shell) to effectively background a process, but
5+
instead it kills it!
6+
7+
diff --git a/etc/rc.d/rc.subr b/etc/rc.d/rc.subr
8+
index 1f872f0ebc8..0c32b00e2ef 100644
9+
--- a/etc/rc.d/rc.subr
10+
+++ b/etc/rc.d/rc.subr
11+
@@ -178,7 +178,7 @@ rc_exec() {
12+
${daemon_execdir:+cd ${daemon_execdir} && } \
13+
$@ \
14+
${daemon_logger:+ 2>&1 |
15+
- logger -isp ${daemon_logger} -t ${_name}}"
16+
+ logger -isp ${daemon_logger} -t ${_name}}; exit"
17+
}
18+
19+
rc_start() {

pkgs/os-specific/bsd/openbsd/pkgs/rc/package.nix

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ mkDerivation {
55
pname = "rc";
66
path = "etc";
77

8-
patches = [ ./boot-phases.patch ];
8+
patches = [
9+
./boot-phases.patch
10+
./binsh-is-bash.patch
11+
];
912

1013
buildPhase = ":";
1114

0 commit comments

Comments
 (0)