comparison src/sysdep.c @ 263:727739f917cb r20-5b30

Import from CVS: tag r20-5b30
author cvs
date Mon, 13 Aug 2007 10:24:41 +0200
parents 11cf20601dec
children c5d627a313b1
comparison
equal deleted inserted replaced
262:9d8607af9e13 263:727739f917cb
631 631
632 /* Use our buffer's default directory for the subshell. */ 632 /* Use our buffer's default directory for the subshell. */
633 if (str) 633 if (str)
634 sys_chdir (str); 634 sys_chdir (str);
635 635
636 #if !defined (NO_SUBPROCESSES) 636 #if !defined (NO_SUBPROCESSES) && !defined (WINDOWSNT)
637 close_process_descs (); /* Close Emacs's pipes/ptys */ 637 close_process_descs (); /* Close Emacs's pipes/ptys */
638 #endif 638 #endif
639 639
640 #ifdef SET_EMACS_PRIORITY 640 #ifdef SET_EMACS_PRIORITY
641 if (emacs_priority != 0) 641 if (emacs_priority != 0)
715 * but I don't know how to do it, so... 715 * but I don't know how to do it, so...
716 */ 716 */
717 #if defined (SIGTSTP) && !defined (MSDOS) 717 #if defined (SIGTSTP) && !defined (MSDOS)
718 kill(process, SIGTSTP); 718 kill(process, SIGTSTP);
719 #endif 719 #endif
720 }
721
722
723 /* Given FD, obtain pty buffer size. When no luck, a good guess is made,
724 so that the function works even fd is not a pty. */
725
726 int
727 get_pty_max_bytes (int fd)
728 {
729 int pty_max_bytes;
730
731 #if defined (HAVE_FPATHCONF) && defined (_PC_MAX_CANON)
732 pty_max_bytes = fpathconf (fd, _PC_MAX_CANON);
733 if (pty_max_bytes < 0)
734 #endif
735 pty_max_bytes = 250;
736
737 /* Deduct one, to leave space for the eof. */
738 pty_max_bytes--;
739
740 return pty_max_bytes;
741 }
742
743 /* Figure out the eof character for the FD. */
744
745 Bufbyte
746 get_eof_char (int fd)
747 {
748 CONST Bufbyte ctrl_d = (Bufbyte) '\004';
749
750 if (!isatty (fd))
751 return ctrl_d;
752 #ifdef HAVE_TERMIOS
753 {
754 struct termios t;
755 tcgetattr (fd, &t);
756 #if 0
757 /* What is the following line designed to do??? -mrb */
758 if (strlen ((CONST char *) t.c_cc) < (unsigned int) (VEOF + 1))
759 return ctrl_d;
760 else
761 return (Bufbyte) t.c_cc[VEOF];
762 #endif
763 return t.c_cc[VEOF] == CDISABLE ? ctrl_d : (Bufbyte) t.c_cc[VEOF];
764 }
765 #else /* ! HAVE_TERMIOS */
766 /* On Berkeley descendants, the following IOCTL's retrieve the
767 current control characters. */
768 #if defined (TIOCGETC)
769 {
770 struct tchars c;
771 ioctl (fd, TIOCGETC, &c);
772 return (Bufbyte) c.t_eofc;
773 }
774 #else /* ! defined (TIOCGLTC) && defined (TIOCGETC) */
775 /* On SYSV descendants, the TCGETA ioctl retrieves the current control
776 characters. */
777 #ifdef TCGETA
778 {
779 struct termio t;
780 ioctl (fd, TCGETA, &t);
781 if (strlen ((CONST char *) t.c_cc) < (unsigned int) (VINTR + 1))
782 return ctrl_d;
783 else
784 return (Bufbyte) t.c_cc[VINTR];
785 }
786 #else /* ! defined (TCGETA) */
787 /* Rather than complain, we'll just guess ^D, which is what
788 * earlier emacsen always used. */
789 return ctrl_d;
790 #endif /* ! defined (TCGETA) */
791 #endif /* ! defined (TIOCGETC) */
792 #endif /* ! defined (HAVE_TERMIOS) */
720 } 793 }
721 794
722 /* Set the logical window size associated with descriptor FD 795 /* Set the logical window size associated with descriptor FD
723 to HEIGHT and WIDTH. This is used mainly with ptys. */ 796 to HEIGHT and WIDTH. This is used mainly with ptys. */
724 797