Skip to content

Commit

Permalink
page: fix hang for forward-only postscript files
Browse files Browse the repository at this point in the history
Page was hanging because ghostscript never closes the fd from which
we're reading BMP data. We close our end of the pipe so that ghostscript
will close its end.

Tested with ghostscript version 9.50.

Fixes #124
  • Loading branch information
fhs authored and dancrossnyc committed Nov 14, 2019
1 parent 436ff26 commit 4660627
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/cmd/page/cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,12 @@ raproc(void *a)

c = a;
lockdisplay(display);
_cachedpage(c->doc, c->angle, c->page, "-ra");
/*
* If there is only one page in a fwdonly file, we may reach EOF
* while doing readahead and page will exit without showing anything.
*/
if(!c->doc->fwdonly)
_cachedpage(c->doc, c->angle, c->page, "-ra");
rabusy = 0;
unlockdisplay(display);
free(c);
Expand Down
1 change: 1 addition & 0 deletions src/cmd/page/ps.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ initps(Biobuf *b, int argc, char **argv, uchar *buf, int nbuf)
if(dumb) {
fprint(ps->gs.gsfd, "(%s) run PAGEFLUSH\n", argv[0]);
fprint(ps->gs.gsfd, "(/dev/fd/3) (w) file dup (THIS IS NOT A PLAN9 BITMAP 01234567890123456789012345678901234567890123456789\\n) writestring flushfile\n");
close(ps->gs.gsfd);
}

ps->bbox = bbox;
Expand Down

0 comments on commit 4660627

Please sign in to comment.