libdraw: use proper pipe for default font data
May fix a deadlock / missing font on OpenBSD. Fixes #308.
This commit is contained in:
parent
4c54893156
commit
4ae529dbfe
1 changed files with 16 additions and 6 deletions
|
|
@ -53,15 +53,25 @@ _getsubfont(Display *d, char *name)
|
||||||
static int
|
static int
|
||||||
defaultpipe(void)
|
defaultpipe(void)
|
||||||
{
|
{
|
||||||
int p[2];
|
int p[2], pid;
|
||||||
|
|
||||||
// assuming defontdata (<5k) fits in pipe buffer.
|
// Used to assume that defontdata (<5k) fit in the
|
||||||
// especially reasonable since p9pipe is actually
|
// pipe buffer, especially since p9pipe is actually
|
||||||
// a socket pair.
|
// a socket pair. But OpenBSD in particular saw hangs,
|
||||||
|
// so feed the pipe it the "right" way with a subprocess.
|
||||||
if(pipe(p) < 0)
|
if(pipe(p) < 0)
|
||||||
return -1;
|
return -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);
|
write(p[1], defontdata, sizeof defontdata);
|
||||||
close(p[1]);
|
close(p[1]);
|
||||||
|
_exit(0);
|
||||||
|
}
|
||||||
return p[0];
|
return p[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue