1 |
/* Asynchronous subprocess control for GNU Emacs. |
/* Asynchronous subprocess control for GNU Emacs. |
2 |
Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 96, 98, 1999, |
Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 96, 98, 1999, |
3 |
2001, 2002 Free Software Foundation, Inc. |
2001, 2002, 2003 Free Software Foundation, Inc. |
4 |
|
|
5 |
This file is part of GNU Emacs. |
This file is part of GNU Emacs. |
6 |
|
|
459 |
int |
int |
460 |
allocate_pty () |
allocate_pty () |
461 |
{ |
{ |
|
struct stat stb; |
|
462 |
register int c, i; |
register int c, i; |
463 |
int fd; |
int fd; |
464 |
|
|
|
/* Some systems name their pseudoterminals so that there are gaps in |
|
|
the usual sequence - for example, on HP9000/S700 systems, there |
|
|
are no pseudoterminals with names ending in 'f'. So we wait for |
|
|
three failures in a row before deciding that we've reached the |
|
|
end of the ptys. */ |
|
|
int failed_count = 0; |
|
|
|
|
465 |
#ifdef PTY_ITERATION |
#ifdef PTY_ITERATION |
466 |
PTY_ITERATION |
PTY_ITERATION |
467 |
#else |
#else |
478 |
#ifdef PTY_OPEN |
#ifdef PTY_OPEN |
479 |
PTY_OPEN; |
PTY_OPEN; |
480 |
#else /* no PTY_OPEN */ |
#else /* no PTY_OPEN */ |
481 |
#ifdef IRIS |
{ |
482 |
/* Unusual IRIS code */ |
struct stat stb; |
483 |
*ptyv = emacs_open ("/dev/ptc", O_RDWR | O_NDELAY, 0); |
# ifdef IRIS |
484 |
if (fd < 0) |
/* Unusual IRIS code */ |
485 |
return -1; |
*ptyv = emacs_open ("/dev/ptc", O_RDWR | O_NDELAY, 0); |
486 |
if (fstat (fd, &stb) < 0) |
if (fd < 0) |
487 |
return -1; |
return -1; |
488 |
#else /* not IRIS */ |
if (fstat (fd, &stb) < 0) |
489 |
if (stat (pty_name, &stb) < 0) |
return -1; |
490 |
{ |
# else /* not IRIS */ |
491 |
failed_count++; |
{ /* Some systems name their pseudoterminals so that there are gaps in |
492 |
if (failed_count >= 3) |
the usual sequence - for example, on HP9000/S700 systems, there |
493 |
return -1; |
are no pseudoterminals with names ending in 'f'. So we wait for |
494 |
|
three failures in a row before deciding that we've reached the |
495 |
|
end of the ptys. */ |
496 |
|
int failed_count = 0; |
497 |
|
|
498 |
|
if (stat (pty_name, &stb) < 0) |
499 |
|
{ |
500 |
|
failed_count++; |
501 |
|
if (failed_count >= 3) |
502 |
|
return -1; |
503 |
|
} |
504 |
|
else |
505 |
|
failed_count = 0; |
506 |
} |
} |
507 |
else |
# ifdef O_NONBLOCK |
508 |
failed_count = 0; |
fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
509 |
#ifdef O_NONBLOCK |
# else |
510 |
fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); |
fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); |
511 |
#else |
# endif |
512 |
fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); |
# endif /* not IRIS */ |
513 |
#endif |
} |
|
#endif /* not IRIS */ |
|
514 |
#endif /* no PTY_OPEN */ |
#endif /* no PTY_OPEN */ |
515 |
|
|
516 |
if (fd >= 0) |
if (fd >= 0) |
526 |
if (access (pty_name, 6) != 0) |
if (access (pty_name, 6) != 0) |
527 |
{ |
{ |
528 |
emacs_close (fd); |
emacs_close (fd); |
529 |
#if !defined(IRIS) && !defined(__sgi) |
# if !defined(IRIS) && !defined(__sgi) |
530 |
continue; |
continue; |
531 |
#else |
# else |
532 |
return -1; |
return -1; |
533 |
#endif /* IRIS */ |
# endif /* IRIS */ |
534 |
} |
} |
535 |
#endif /* not UNIPLUS */ |
#endif /* not UNIPLUS */ |
536 |
setup_pty (fd); |
setup_pty (fd); |
2206 |
int len; |
int len; |
2207 |
{ |
{ |
2208 |
register struct Lisp_Vector *p; |
register struct Lisp_Vector *p; |
2209 |
register unsigned char *cp; |
register unsigned char *cp = NULL; |
2210 |
register int i; |
register int i; |
2211 |
|
|
2212 |
bzero (sa, len); |
bzero (sa, len); |