1

i3status-timers.json-io: remap stdio to /dev/null on spawn()

This commit is contained in:
eleksir
2020-03-15 21:08:08 +03:00
parent 0324616c01
commit b6d1722b25

View File

@@ -508,9 +508,10 @@ sub spawn (@) {
return; return;
} elsif ($pid == 0) { # Child } elsif ($pid == 0) { # Child
# we need no io streams here, right? # we need no io streams here, right?
close STDOUT; # it seems that at least vscode creashes if we close stdio handles
close STDERR; open(STDOUT, ">", "/dev/null");
close STDIN; open(STDERR, ">", "/dev/null");
open(STDIN, "<", "/dev/null");
my $prg = shift(@args); my $prg = shift(@args);
# weird situation, silently quit here :) # weird situation, silently quit here :)
exit 0 unless(defined($prg)); exit 0 unless(defined($prg));
@@ -521,6 +522,6 @@ sub spawn (@) {
exec $prg; exec $prg;
} }
} else { # Unable to fork() } else { # Unable to fork()
warn "ERROR: Could not fork new process: $!\n"; syswrite STDERR, "[{\"full_text\":\"ERROR: Could not fork new process: $!\",\"color\":\"#ff0000\"}],\n";
} }
} }