summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Drew DeVault <sir@cmpwn.com>2017-09-12 21:26:34 +0900
committerLibravatar GitHub <noreply@github.com>2017-09-12 21:26:34 +0900
commitec9a977fbbdf7ed6134ad95d7ce8bee793243ee8 (patch)
tree8d17ab39341f29d36983fe069793139498feeb0c
parentMerge pull request #1342 from DarkReef/master (diff)
parentfixes a hanging swaygrab (diff)
downloadsway-ec9a977fbbdf7ed6134ad95d7ce8bee793243ee8.tar.gz
sway-ec9a977fbbdf7ed6134ad95d7ce8bee793243ee8.tar.zst
sway-ec9a977fbbdf7ed6134ad95d7ce8bee793243ee8.zip
Merge pull request #1351 from Ongy/swaygrab-forking
fixes a hanging swaygrab
-rw-r--r--swaygrab/main.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/swaygrab/main.c b/swaygrab/main.c
index 6e851899..1b699bb9 100644
--- a/swaygrab/main.c
+++ b/swaygrab/main.c
@@ -58,14 +58,19 @@ void grab_and_apply_magick(const char *file, const char *payload,
58 if ((child = fork()) < 0) { 58 if ((child = fork()) < 0) {
59 sway_log(L_ERROR, "Swaygrab failed to fork."); 59 sway_log(L_ERROR, "Swaygrab failed to fork.");
60 exit(EXIT_FAILURE); 60 exit(EXIT_FAILURE);
61 } else if (child == 0) { 61 } else if (child != 0) {
62 close(fd[0]);
63 write(fd[1], pixels, len);
62 close(fd[1]); 64 close(fd[1]);
63 write(fd[0], pixels, len);
64 free(pixels - 9); 65 free(pixels - 9);
65 waitpid(child, NULL, 0); 66 waitpid(child, NULL, 0);
66 } else { 67 } else {
68 close(fd[1]);
69 if (dup2(fd[0], 0) != 0) {
70 sway_log(L_ERROR, "Could not fdup the pipe");
71 }
67 close(fd[0]); 72 close(fd[0]);
68 execlp("convert", "-depth", "8", "-size", size, "rgba:-", "-flip", file, NULL); 73 execlp("convert", "convert", "-depth", "8", "-size", size, "rgba:-", "-flip", file, NULL);
69 sway_log(L_ERROR, "Swaygrab could not run convert."); 74 sway_log(L_ERROR, "Swaygrab could not run convert.");
70 exit(EXIT_FAILURE); 75 exit(EXIT_FAILURE);
71 } 76 }
@@ -104,7 +109,7 @@ void grab_and_apply_movie_magic(const char *file, const char *payload,
104 "-video_size %dx%d -pixel_format argb " 109 "-video_size %dx%d -pixel_format argb "
105 "-i pipe:0 -r %d -vf vflip %s"; 110 "-i pipe:0 -r %d -vf vflip %s";
106 char *cmd = malloc(strlen(fmt) - 8 /*args*/ 111 char *cmd = malloc(strlen(fmt) - 8 /*args*/
107 + strlen(ffmpeg_opts) + numlen(width) + numlen(height) 112 + strlen(ffmpeg_opts) + numlen(width) + numlen(height)
108 + numlen(framerate) * 2 + strlen(file) + 1); 113 + numlen(framerate) * 2 + strlen(file) + 1);
109 sprintf(cmd, fmt, ffmpeg_opts, framerate, width, height, framerate, file); 114 sprintf(cmd, fmt, ffmpeg_opts, framerate, width, height, framerate, file);
110 115