Skip to content

Event --on-process-exit is delayed until pipeline exits #8914

@mliszcz

Description

@mliszcz

I'm using version: 3.4.1 and 3.3.1-529-gc4fb857da

I noticed this change after upgrade from 3.3.1:

  • there are two processes connected with a pipe: process1 | process2 &,
  • there is a function set up with --on-process-exit for process1 PID,
  • in 3.3.1 the function is called immediately after process1 exits,
  • in 3.4.1 the function is called only after process2 exits.

In my use case, process1 is asynchronously generating prompt text while process2 is tee, to work around #7422 as described here.

Below is a minimal example how to reproduce the problem. I'm running fish with an empty home directory. I created the fifo with mkfifo.

mkdir /tmp/fishhome
mkfifo /tmp/fishhome/fifo
env HOME=/tmp/fishhome fish

3.3.1 (00a1df3): callback is called as soon as I unblock the events and the /usr/bin/echo exits.

miliszcz@krling168 /h/miliszcz> block -g
miliszcz@krling168 /h/miliszcz> /usr/bin/echo background | tee /tmp/fishhome/fifo >/dev/null &
miliszcz@krling168 /h/miliszcz> function cb --on-process-exit (jobs --last --pid)[1]; echo called; end
miliszcz@krling168 /h/miliszcz> block -e
called
miliszcz@krling168 /h/miliszcz> cat /tmp/fishhome/fifo
background
fish: Job 1, '/usr/bin/echo background | tee…' has ended

3.4.1 (c4fb857): nothing happens until I read the fifo and make the tee exit. I checked the order of PIDs returned by jobs --last --pid, but it is the same as in 3.3.1. After I call block -e, the echo process does not exist, only tee is waiting.

miliszcz@krling168 /h/miliszcz> block -g
miliszcz@krling168 /h/miliszcz> /usr/bin/echo background | tee /tmp/fishhome/fifo >/dev/null &
miliszcz@krling168 /h/miliszcz> function cb --on-process-exit (jobs --last --pid)[1]; echo called; end
miliszcz@krling168 /h/miliszcz> block -e
miliszcz@krling168 /h/miliszcz> cat /tmp/fishhome/fifo
background
fish: Job 1, '/usr/bin/echo background | tee…' has ended
called

I bisected the commits between 3.3.1 and 3.4.1. It turns out that the change was introduced in c4fb857. Judging from the commit message it was not intentional, thus this looks like a bug.

Unfortunately I am unable to analyze the changes in this commit, it requires some knowledge of the inner workings of fish which is a bit beyond me. Thanks in advance for help!

CC @ridiculousfish as author of c4fb857.

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions