aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRuss Cox <rsc@swtch.com>2020-01-14 13:18:29 -0500
committerRuss Cox <rsc@swtch.com>2020-01-14 13:32:17 -0500
commit4ae529dbfe8573ae105d0d66f7f453c4f850fa1f (patch)
tree9de147163e6fa19dcc964f6fac8d4a86cacf4e41 /src
parent4c54893156cf2489081fe63eb37a0e4d3ede1e05 (diff)
downloadplan9port-4ae529dbfe8573ae105d0d66f7f453c4f850fa1f.tar.gz
plan9port-4ae529dbfe8573ae105d0d66f7f453c4f850fa1f.tar.bz2
plan9port-4ae529dbfe8573ae105d0d66f7f453c4f850fa1f.zip
libdraw: use proper pipe for default font data
May fix a deadlock / missing font on OpenBSD. Fixes #308.
Diffstat (limited to 'src')
-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];
}