mirror of
https://github.com/fish-shell/fish-shell
synced 2024-12-28 13:53:10 +00:00
Add a tricky test to verify disowning an in-flight job
There's some logic in fish to prevent blowing up when an under-construction job is disowned. Add a test for it.
This commit is contained in:
parent
2ec8cd3bca
commit
d47541a3d7
2 changed files with 22 additions and 0 deletions
|
@ -46,6 +46,12 @@ static void print_stdout_stderr() {
|
|||
fflush(nullptr);
|
||||
}
|
||||
|
||||
static void print_pid_then_sleep() {
|
||||
fprintf(stdout, "%d\n", getpid());
|
||||
fflush(nullptr);
|
||||
usleep(1000000 / .5); //.5 secs
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
if (argc <= 1) {
|
||||
fprintf(stderr, "No commands given.\n");
|
||||
|
@ -60,6 +66,8 @@ int main(int argc, char *argv[]) {
|
|||
sigint_parent();
|
||||
} else if (!strcmp(argv[i], "print_stdout_stderr")) {
|
||||
print_stdout_stderr();
|
||||
} else if (!strcmp(argv[i], "print_pid_then_sleep")) {
|
||||
print_pid_then_sleep();
|
||||
} else {
|
||||
fprintf(stderr, "%s: Unknown command: %s\n", argv[0], argv[i]);
|
||||
return EXIT_FAILURE;
|
||||
|
|
14
tests/checks/disown-parent.fish
Normal file
14
tests/checks/disown-parent.fish
Normal file
|
@ -0,0 +1,14 @@
|
|||
# RUN: env fish_test_helper=%fish_test_helper %fish %s
|
||||
|
||||
# Ensure that a job which attempts to disown itself does not explode.
|
||||
# Here fish_test_helper is the process group leader; we attempt to disown
|
||||
# its pid within a pipeline containing it.
|
||||
|
||||
function disowner
|
||||
read -l pid
|
||||
echo Disown $pid
|
||||
disown $pid
|
||||
end
|
||||
$fish_test_helper print_pid_then_sleep | disowner
|
||||
|
||||
# CHECK: Disown {{\d+}}
|
Loading…
Reference in a new issue