Skip to content

Commit

Permalink
vis: correctly close pipe connected to stdin of external process
Browse files Browse the repository at this point in the history
Once we have written all data we should properly close the (correct)
pipe. Before we wrongly closed the pipe connected to the standard output
stream.

More generally, we currently do not listen for child process termination,
but instead wait until all the connected pipes are closed. This might
be problematic in case the external process keeps hold of the standard
I/O file descriptors. One particular example of this is wl-copy(1).

See martanne#929
  • Loading branch information
martanne committed Feb 15, 2021
1 parent 1ace716 commit 0cccd6e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions vis.c
Original file line number Diff line number Diff line change
Expand Up @@ -1860,8 +1860,8 @@ int vis_pipe(Vis *vis, File *file, Filerange *range, const char *argv[],
if (len > 0) {
rout.start += len;
if (text_range_size(&rout) == 0) {
close(pout[1]);
pout[1] = -1;
close(pin[1]);
pin[1] = -1;
}
} else {
close(pin[1]);
Expand Down

0 comments on commit 0cccd6e

Please sign in to comment.