source:
trunk/patches/ptmx.patch
@
5
Last change on this file since 5 was 5, checked in by bas, 17 years ago | |
---|---|
File size: 1.8 KB |
-
src/resmom/linux/mom_start.c
old new 78 78 */ 79 79 #include <pbs_config.h> /* the master config generated by configure */ 80 80 81 #include <stdlib.h> /* for unix98 pty api in open_master */ 81 82 #include <string.h> 82 83 #include <unistd.h> 83 84 #include <pwd.h> … … 356 357 * piece of code depends on multiplexor /dev/ptc 357 358 */ 358 359 359 #define PTY_SIZE 12360 360 361 361 int open_master( 362 362 363 363 char **rtn_name) /* RETURN name of slave pts */ 364 364 365 365 { 366 char *pc1;367 char *pc2;368 366 int ptc; /* master file descriptor */ 369 static char ptcchar1[] = "pqrs";370 static char ptcchar2[] = "0123456789abcdef";371 static char pty_name[PTY_SIZE+1]; /* "/dev/[pt]tyXY" */372 367 373 strncpy(pty_name, "/dev/ptyXY", PTY_SIZE); 374 375 for (pc1 = ptcchar1;*pc1 != '\0';++pc1) 368 if ((ptc = open("/dev/ptmx",O_RDWR|O_NOCTTY)) >= 0) 376 369 { 377 pty_name[8] = *pc1; 378 379 for (pc2 = ptcchar2;*pc2 != '\0';++pc2) 380 { 381 pty_name[9] = *pc2; 382 383 if ((ptc = open(pty_name,O_RDWR|O_NOCTTY,0)) >= 0) 384 { 385 /* got a master, fix name to matching slave */ 386 387 pty_name[5] = 't'; 388 389 *rtn_name = pty_name; 390 370 /* got a master, fix name to matching slave */ 371 if (grantpt(ptc)<0 || unlockpt(ptc)<0) 372 { 373 close(ptc); 374 return(-1); 375 } 376 *rtn_name = (char *) ptsname(ptc); /* never to be freed */ 377 if (*rtn_name == NULL) 378 { 379 close(ptc); 380 return(-1); 381 } 391 382 return(ptc); 392 } 393 else if (errno == ENOENT) 394 { 395 return(-1); /* tried all entries, give up */ 396 } 397 } 398 } 399 400 return(-1); /* tried all entries, give up */ 383 } 384 return(-1); /* give up */ 401 385 } /* END open_master() */ 402 386
Note: See TracBrowser
for help on using the repository browser.