commit - 4c54893156cf2489081fe63eb37a0e4d3ede1e05
commit + 4ae529dbfe8573ae105d0d66f7f453c4f850fa1f
blob - ec4ccfe3ed7fe2f1dbc59f9b912352d90f42ef0b
blob + 1cc234ef9d319bedc6f2c46adcd063b7f2b95ecf
--- src/libdraw/getsubfont.c
+++ src/libdraw/getsubfont.c
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];
}