aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/libdraw/getsubfont.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/libdraw/getsubfont.c b/src/libdraw/getsubfont.c
index ec4ccfe3..1cc234ef 100644
--- a/src/libdraw/getsubfont.c
+++ b/src/libdraw/getsubfont.c
@@ -53,15 +53,25 @@ _getsubfont(Display *d, char *name)
static int
defaultpipe(void)
{
- int p[2];
+ int p[2], pid;
- // assuming defontdata (<5k) fits in pipe buffer.
- // especially reasonable since p9pipe is actually
- // a socket pair.
+ // Used to assume that defontdata (<5k) fit in the
+ // pipe buffer, especially since p9pipe is actually
+ // a socket pair. But OpenBSD in particular saw hangs,
+ // so feed the pipe it the "right" way with a subprocess.
if(pipe(p) < 0)
return -1;
- write(p[1], defontdata, sizeof defontdata);
- close(p[1]);
+ if((pid = fork()) < 0) {
+ close(p[0]);
+ close(p[1]);
+ return -1;
+ }
+ if(pid == 0) {
+ close(p[0]);
+ write(p[1], defontdata, sizeof defontdata);
+ close(p[1]);
+ _exit(0);
+ }
return p[0];
}