mirror of
https://github.com/9fans/plan9port.git
synced 2025-01-12 11:10:07 +00:00
9term: fix getpts on linux
Openpty uses grantpt internally and its behavior is unspecified when a handler is set to catch SIGCHLD. Fixes issue 37. http://code.swtch.com/plan9port/issues/37 R=rsc CC=codebot http://codereview.appspot.com/1209049
This commit is contained in:
parent
670f730113
commit
c988c8adf1
2 changed files with 6 additions and 0 deletions
|
@ -5,6 +5,7 @@
|
|||
|
||||
Albert Lee <trisk@acm.jhu.edu>
|
||||
André Günther <Andre.G@gmx.de>
|
||||
Anthony Martin <ality@pbrane.org>
|
||||
Anthony Sorace <a@9srv.net>
|
||||
Arvindh Rajesh Tamilmani <art@a-30.net>
|
||||
Benjamin Huntsman <BHuntsman@mail2.cu-portland.edu>
|
||||
|
|
|
@ -1,13 +1,18 @@
|
|||
#define getpts not_using_this_getpts
|
||||
#include "bsdpty.c"
|
||||
#undef getpts
|
||||
#include <signal.h>
|
||||
|
||||
int
|
||||
getpts(int fd[], char *slave)
|
||||
{
|
||||
void (*f)(int);
|
||||
|
||||
f = signal(SIGCHLD, SIG_DFL);
|
||||
if(openpty(&fd[1], &fd[0], NULL, NULL, NULL) >= 0){
|
||||
fchmod(fd[1], 0620);
|
||||
strcpy(slave, ttyname(fd[0]));
|
||||
signal(SIGCHLD, f);
|
||||
return 0;
|
||||
}
|
||||
sysfatal("no ptys");
|
||||
|
|
Loading…
Reference in a new issue