From 4ae529dbfe8573ae105d0d66f7f453c4f850fa1f Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 13:18:29 -0500 Subject: libdraw: use proper pipe for default font data May fix a deadlock / missing font on OpenBSD. Fixes #308. --- src/libdraw/getsubfont.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'src/libdraw') 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]; } -- cgit v1.2.3 From 40d787ab1276f191bcf030748a954d6708d83228 Mon Sep 17 00:00:00 2001 From: Russ Cox Date: Tue, 14 Jan 2020 18:05:51 -0500 Subject: libdraw: send hangup to process when window is lost This matches the Plan 9 behavior a bit better. Fixes #30. --- src/libdraw/mouse.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/libdraw') diff --git a/src/libdraw/mouse.c b/src/libdraw/mouse.c index 64a7f73d..382efae5 100644 --- a/src/libdraw/mouse.c +++ b/src/libdraw/mouse.c @@ -52,8 +52,12 @@ _ioproc(void *arg) one = 1; resized = 0; for(;;){ - if(_displayrdmouse(mc->display, &m, &resized) < 0) + if(_displayrdmouse(mc->display, &m, &resized) < 0) { + if(postnote(PNPROC, getpid(), "hangup") < 0) + fprint(2, "postnote: %r\n"); + sleep(10*1000); threadexitsall("mouse read error"); + } if(resized) send(mc->resizec, &one); send(mc->c, &m); -- cgit v1.2.3