diff options
author | Drew DeVault <sir@cmpwn.com> | 2017-09-12 21:26:34 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-12 21:26:34 +0900 |
commit | ec9a977fbbdf7ed6134ad95d7ce8bee793243ee8 (patch) | |
tree | 8d17ab39341f29d36983fe069793139498feeb0c /swaygrab | |
parent | 5e8f83fbd61d77a7a84ae789f606a1dfc0d01f3c (diff) | |
parent | 22656ae1e423918eb3bbee78c463e4cd190491de (diff) |
Merge pull request #1351 from Ongy/swaygrab-forking
fixes a hanging swaygrab
Diffstat (limited to 'swaygrab')
-rw-r--r-- | swaygrab/main.c | 13 |
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, if ((child = fork()) < 0) { sway_log(L_ERROR, "Swaygrab failed to fork."); exit(EXIT_FAILURE); - } else if (child == 0) { + } else if (child != 0) { + close(fd[0]); + write(fd[1], pixels, len); close(fd[1]); - write(fd[0], pixels, len); free(pixels - 9); waitpid(child, NULL, 0); } else { + close(fd[1]); + if (dup2(fd[0], 0) != 0) { + sway_log(L_ERROR, "Could not fdup the pipe"); + } 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."); exit(EXIT_FAILURE); } @@ -104,7 +109,7 @@ void grab_and_apply_movie_magic(const char *file, const char *payload, "-video_size %dx%d -pixel_format argb " "-i pipe:0 -r %d -vf vflip %s"; char *cmd = malloc(strlen(fmt) - 8 /*args*/ - + strlen(ffmpeg_opts) + numlen(width) + numlen(height) + + strlen(ffmpeg_opts) + numlen(width) + numlen(height) + numlen(framerate) * 2 + strlen(file) + 1); sprintf(cmd, fmt, ffmpeg_opts, framerate, width, height, framerate, file); |