Commit Graph

15 Commits

Author SHA1 Message Date
ridiculousfish
b9a95a48b4 Test that --on-job-exit functions run even if the job has already exited
If you define a function that you want to be called after a job has
exited, it should run immediately if that job has already exited.
2021-10-28 10:02:48 -07:00
Johannes Altmanninger
bd79e753ff Fix detection of zombies in test
Due to the second column the old glob no longer worked.
2021-08-29 20:22:16 +02:00
Mahmoud Al-Qudsi
efda4f5c39 Make zombie test smarter
Instead of trying to assert that there are no zombies when the test
starts (which often fails) and to prevent conflating existing or
irrelevant zombies with the ones we are interested in checking for,
have `ps` also emit the parent process id and filter its output to
include only children of the current fish instance.
2021-08-29 08:56:12 +02:00
Fabian Homborg
66bc6ce77d Try to fix tests for Solaris' ps 2021-06-24 18:19:28 +02:00
ridiculousfish
08950b1077 Revert "Bravely set job control to full at startup"
Now that `$last_pid` is never fish's pid, we no longer need to force
jobs to run in their own pgroup. Restore the job control behavior to
what it was prior, so that signals may be delivered properly in
non-interactive mode.

This reverts commit 3255999794
2021-05-25 15:28:53 -07:00
ridiculousfish
33f3c03dae Allow on-job-exit handlers to be added for any pid in the job
Prior to this change, a function with an on-job-exit event handler must be
added with the pgid of the job. But sometimes the pgid of the job is fish
itself (if job control is disabled) and the previous commit made last_pid
an actual pid from the job, instead of its pgroup.

Switch on-job-exit to accept any pid from the job (except fish itself).
This allows it to be used directly with $last_pid, except that it now
works if job control is off. This is implemented by "resolving" the pid to
the internal job id at the point the event handler is added.

Also switch to passing the last pid of the job, rather than its pgroup.
This aligns better with $last_pid.
2021-05-25 15:28:53 -07:00
Fabian Homborg
3255999794 Bravely set job control to full at startup
We have no idea why this was even a thing. For now simply set it to
"all"/"full" (why these two names? no idea) at startup and allow
changing it later.

Settting it *immediately* when defining the variable sets it too soon
because we don't have the interactive signal handlers
enabled (including the one for SIGTTOU), so let's first settle for
this little piece of awkwardness.

This needs widespread testing, so we merge it early, immediately after
the release.

Fixes #5036
Fixes #5832
Fixes #7721

(and probably numerous others)
2021-03-26 19:32:14 +01:00
Fabian Homborg
56e1109609 Add test for caller-exit events
This was a bit fiddly!
2021-03-07 10:22:35 +01:00
ridiculousfish
1fd9debaad jobs test to detect zombies before running
If there is any zombie process, the jobs.fish test will fail. Add an
explicit check to report when this happens.
2020-09-13 19:28:14 -07:00
Fabian Homborg
7de333f839 tests: jobs: Sleep more
This one sometimes fails with a zombie detected, so I'm assuming it's
too fast for reaping to happen, so we add another 100ms sleep.

Yeah, this isn't great but...eh
2020-08-08 16:35:08 +02:00
Fabian Homborg
f63d70298f tests: Use ps -o stat instead of "state"
Oh, Alpine
2020-08-07 21:06:16 +02:00
David Adam
2c5d4937e3 disown: add tests for disowned jobs in scripts 2020-07-25 20:38:59 -05:00
Soumya
96563d6eff jobs: suppress "No suitable job" if -q is given
This allows code of the form `if jobs -q $some_pid` in scripts to check whether a previously started job is still running. Previously this would return the correct value, but also print an error message.

The invalid argument errors will still be printed.
Added test cases for both.
2020-03-26 17:09:09 +01:00
Fabian Homborg
9367d4ff71 Reindent functions to remove useless quotes
This does not include checks/function.fish because that currently
includes a "; end" in a message that indent would remove, breaking the test.
2020-03-09 19:46:43 +01:00
Fabian Homborg
2fa8ae161a Port jobs test to littlecheck 2020-02-08 09:47:14 +01:00