comparison src/process.c @ 51233:41ed31a0fd49

(allocate_pty): Remove `unused var stb' and `cp might be used uninitialized' warnings.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Sun, 25 May 2003 17:43:20 +0000
parents 2c49296df7d3
children 58061223557c
comparison
equal deleted inserted replaced
51232:07dc24e888c8 51233:41ed31a0fd49
1 /* Asynchronous subprocess control for GNU Emacs. 1 /* Asynchronous subprocess control for GNU Emacs.
2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 96, 98, 1999, 2 Copyright (C) 1985, 86, 87, 88, 93, 94, 95, 96, 98, 1999,
3 2001, 2002 Free Software Foundation, Inc. 3 2001, 2002, 2003 Free Software Foundation, Inc.
4 4
5 This file is part of GNU Emacs. 5 This file is part of GNU Emacs.
6 6
7 GNU Emacs is free software; you can redistribute it and/or modify 7 GNU Emacs is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
457 is left in the variable pty_name. */ 457 is left in the variable pty_name. */
458 458
459 int 459 int
460 allocate_pty () 460 allocate_pty ()
461 { 461 {
462 struct stat stb;
463 register int c, i; 462 register int c, i;
464 int fd; 463 int fd;
465
466 /* Some systems name their pseudoterminals so that there are gaps in
467 the usual sequence - for example, on HP9000/S700 systems, there
468 are no pseudoterminals with names ending in 'f'. So we wait for
469 three failures in a row before deciding that we've reached the
470 end of the ptys. */
471 int failed_count = 0;
472 464
473 #ifdef PTY_ITERATION 465 #ifdef PTY_ITERATION
474 PTY_ITERATION 466 PTY_ITERATION
475 #else 467 #else
476 for (c = FIRST_PTY_LETTER; c <= 'z'; c++) 468 for (c = FIRST_PTY_LETTER; c <= 'z'; c++)
484 #endif /* no PTY_NAME_SPRINTF */ 476 #endif /* no PTY_NAME_SPRINTF */
485 477
486 #ifdef PTY_OPEN 478 #ifdef PTY_OPEN
487 PTY_OPEN; 479 PTY_OPEN;
488 #else /* no PTY_OPEN */ 480 #else /* no PTY_OPEN */
489 #ifdef IRIS 481 {
490 /* Unusual IRIS code */ 482 struct stat stb;
491 *ptyv = emacs_open ("/dev/ptc", O_RDWR | O_NDELAY, 0); 483 # ifdef IRIS
492 if (fd < 0) 484 /* Unusual IRIS code */
493 return -1; 485 *ptyv = emacs_open ("/dev/ptc", O_RDWR | O_NDELAY, 0);
494 if (fstat (fd, &stb) < 0) 486 if (fd < 0)
495 return -1; 487 return -1;
496 #else /* not IRIS */ 488 if (fstat (fd, &stb) < 0)
497 if (stat (pty_name, &stb) < 0) 489 return -1;
498 { 490 # else /* not IRIS */
499 failed_count++; 491 { /* Some systems name their pseudoterminals so that there are gaps in
500 if (failed_count >= 3) 492 the usual sequence - for example, on HP9000/S700 systems, there
501 return -1; 493 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;
502 } 506 }
503 else 507 # ifdef O_NONBLOCK
504 failed_count = 0; 508 fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0);
505 #ifdef O_NONBLOCK 509 # else
506 fd = emacs_open (pty_name, O_RDWR | O_NONBLOCK, 0); 510 fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0);
507 #else 511 # endif
508 fd = emacs_open (pty_name, O_RDWR | O_NDELAY, 0); 512 # endif /* not IRIS */
509 #endif 513 }
510 #endif /* not IRIS */
511 #endif /* no PTY_OPEN */ 514 #endif /* no PTY_OPEN */
512 515
513 if (fd >= 0) 516 if (fd >= 0)
514 { 517 {
515 /* check to make certain that both sides are available 518 /* check to make certain that both sides are available
521 #endif /* no PTY_TTY_NAME_SPRINTF */ 524 #endif /* no PTY_TTY_NAME_SPRINTF */
522 #ifndef UNIPLUS 525 #ifndef UNIPLUS
523 if (access (pty_name, 6) != 0) 526 if (access (pty_name, 6) != 0)
524 { 527 {
525 emacs_close (fd); 528 emacs_close (fd);
526 #if !defined(IRIS) && !defined(__sgi) 529 # if !defined(IRIS) && !defined(__sgi)
527 continue; 530 continue;
528 #else 531 # else
529 return -1; 532 return -1;
530 #endif /* IRIS */ 533 # endif /* IRIS */
531 } 534 }
532 #endif /* not UNIPLUS */ 535 #endif /* not UNIPLUS */
533 setup_pty (fd); 536 setup_pty (fd);
534 return fd; 537 return fd;
535 } 538 }
2201 Lisp_Object address; 2204 Lisp_Object address;
2202 struct sockaddr *sa; 2205 struct sockaddr *sa;
2203 int len; 2206 int len;
2204 { 2207 {
2205 register struct Lisp_Vector *p; 2208 register struct Lisp_Vector *p;
2206 register unsigned char *cp; 2209 register unsigned char *cp = NULL;
2207 register int i; 2210 register int i;
2208 2211
2209 bzero (sa, len); 2212 bzero (sa, len);
2210 sa->sa_family = family; 2213 sa->sa_family = family;
2211 2214