mirror of
https://github.com/swaywm/sway.git
synced 2024-12-29 16:36:26 +01:00
fixes a hanging swaygrab
https://github.com/SirCmpwn/sway/issues/1350 is fixed with this. The commit that change swaygrab to use fork instead of Popen tried to write to the read end of the pipe in the child branch and exec in the parent branch. This commit fixes both of those and closes the write fd after writing, so convert actually exits.
This commit is contained in:
parent
5e8f83fbd6
commit
22656ae1e4
1 changed files with 9 additions and 4 deletions
|
@ -58,14 +58,19 @@ void grab_and_apply_magick(const char *file, const char *payload,
|
||||||
if ((child = fork()) < 0) {
|
if ((child = fork()) < 0) {
|
||||||
sway_log(L_ERROR, "Swaygrab failed to fork.");
|
sway_log(L_ERROR, "Swaygrab failed to fork.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
} else if (child == 0) {
|
} else if (child != 0) {
|
||||||
|
close(fd[0]);
|
||||||
|
write(fd[1], pixels, len);
|
||||||
close(fd[1]);
|
close(fd[1]);
|
||||||
write(fd[0], pixels, len);
|
|
||||||
free(pixels - 9);
|
free(pixels - 9);
|
||||||
waitpid(child, NULL, 0);
|
waitpid(child, NULL, 0);
|
||||||
} else {
|
} else {
|
||||||
|
close(fd[1]);
|
||||||
|
if (dup2(fd[0], 0) != 0) {
|
||||||
|
sway_log(L_ERROR, "Could not fdup the pipe");
|
||||||
|
}
|
||||||
close(fd[0]);
|
close(fd[0]);
|
||||||
execlp("convert", "-depth", "8", "-size", size, "rgba:-", "-flip", file, NULL);
|
execlp("convert", "convert", "-depth", "8", "-size", size, "rgba:-", "-flip", file, NULL);
|
||||||
sway_log(L_ERROR, "Swaygrab could not run convert.");
|
sway_log(L_ERROR, "Swaygrab could not run convert.");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue