comparison src/sysdep.c @ 4759:aa5ed11f473b

Remove support for obsolete systems. See xemacs-patches message with ID <870180fe0911101613m6b8efa4bpf083fd9013950807@mail.gmail.com>.
author Jerry James <james@xemacs.org>
date Wed, 18 Nov 2009 08:49:14 -0700
parents b3d7b8b98acf
children 217abcf015c4
comparison
equal deleted inserted replaced
4758:75975fd0b7fc 4759:aa5ed11f473b
81 /* TTY definitions */ 81 /* TTY definitions */
82 /* ------------------------------- */ 82 /* ------------------------------- */
83 83
84 #ifdef USG 84 #ifdef USG
85 #include <sys/utsname.h> 85 #include <sys/utsname.h>
86 #if defined (TIOCGWINSZ) || defined (ISC4_0)
87 #ifdef NEED_SIOCTL
88 #include <sys/sioctl.h>
89 #endif
90 #ifdef NEED_PTEM_H
91 #include <sys/stream.h>
92 #include <sys/ptem.h>
93 #endif
94 #endif /* TIOCGWINSZ or ISC4_0 */
95 #endif /* USG */ 86 #endif /* USG */
96 87
97 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */ 88 /* LPASS8 is new in 4.3, and makes cbreak mode provide all 8 bits. */
98 #ifndef LPASS8 89 #ifndef LPASS8
99 #define LPASS8 0 90 #define LPASS8 0
113 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200, 104 0, 50, 75, 110, 135, 150, 200, 300, 600, 1200,
114 1800, 2400, 4800, 9600, 19200, 38400 105 1800, 2400, 4800, 9600, 19200, 38400
115 }; 106 };
116 #endif 107 #endif
117 108
118 #endif
119
120 #ifdef AIXHFT
121 static void hft_init (struct console *c);
122 static void hft_reset (struct console *c);
123 #include <sys/termio.h>
124 #endif 109 #endif
125 110
126 #ifdef HAVE_TTY 111 #ifdef HAVE_TTY
127 #define USED_IF_TTY(decl) decl 112 #define USED_IF_TTY(decl) decl
128 #else 113 #else
229 { 214 {
230 /* #### With the new improved SIGCHLD handling stuff, there is much 215 /* #### With the new improved SIGCHLD handling stuff, there is much
231 less danger of race conditions and some of the comments below 216 less danger of race conditions and some of the comments below
232 don't apply. This should be updated. */ 217 don't apply. This should be updated. */
233 218
234 #if defined (NO_SUBPROCESSES) 219 #if defined (HAVE_WAITPID)
235 while (1)
236 {
237 /* No need to be tricky like below; we can just call wait(). */
238 /* #### should figure out how to write a wait_allowing_quit().
239 Since hardly any systems don't have subprocess support,
240 however, there doesn't seem to be much point. */
241 if (wait (0) == pid)
242 return;
243 }
244 #elif defined (HAVE_WAITPID)
245 /* Note that, whenever any subprocess terminates (asynch. or synch.), 220 /* Note that, whenever any subprocess terminates (asynch. or synch.),
246 the SIGCHLD handler will be called and it will call wait(). Thus 221 the SIGCHLD handler will be called and it will call wait(). Thus
247 we cannot just call wait() ourselves, and we can't block SIGCHLD 222 we cannot just call wait() ourselves, and we can't block SIGCHLD
248 and then call wait(), because then if an asynch. process dies 223 and then call wait(), because then if an asynch. process dies
249 while we're waiting for our synch. process, Emacs will never 224 while we're waiting for our synch. process, Emacs will never
380 } 355 }
381 #endif /* OS features */ 356 #endif /* OS features */
382 } 357 }
383 358
384 #endif /* NEED_SYNC_PROCESS_CODE */ 359 #endif /* NEED_SYNC_PROCESS_CODE */
385
386 #if !defined (NO_SUBPROCESSES)
387 360
388 /* 361 /*
389 * flush any pending output 362 * flush any pending output
390 * (may flush input as well; it does not matter the way we use it) 363 * (may flush input as well; it does not matter the way we use it)
391 */ 364 */
542 s.main.sg_kill = 0377; 515 s.main.sg_kill = 0377;
543 s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */ 516 s.lmode = LLITOUT | s.lmode; /* Don't strip 8th bit */
544 517
545 #endif /* not HAVE_TERMIO */ 518 #endif /* not HAVE_TERMIO */
546 emacs_set_tty (out, &s, 0); 519 emacs_set_tty (out, &s, 0);
547
548 #ifdef RTU
549 {
550 int zero = 0;
551 ioctl (out, FIOASYNC, &zero);
552 }
553 #endif /* RTU */
554 } 520 }
555 #endif /* WIN32_NATIVE */ 521 #endif /* WIN32_NATIVE */
556 522
557 #endif /* not NO_SUBPROCESSES */
558
559 523
560 #if !defined (SIGTSTP) && !defined (USG_JOBCTRL) 524 #if !defined (SIGTSTP)
561 525
562 #define SIG_PARAM_TYPE int 526 #define SIG_PARAM_TYPE int
563 527
564 /* Record a signal code and the handler for it. */ 528 /* Record a signal code and the handler for it. */
565 struct save_signal 529 struct save_signal
587 EMACS_SIGNAL (saved_handlers->code, saved_handlers->handler); 551 EMACS_SIGNAL (saved_handlers->code, saved_handlers->handler);
588 saved_handlers++; 552 saved_handlers++;
589 } 553 }
590 } 554 }
591 555
592 556 #endif /* !defined (SIGTSTP) */
593 /* Fork a subshell. */
594 static void
595 sys_subshell (void)
596 {
597 Lisp_Object dir;
598 Ibyte *str = 0;
599 Bytecount len;
600 struct gcpro gcpro1;
601 Ibyte *sh = 0;
602 Extbyte *shext;
603
604 /* Use our buffer's default directory for the subshell. */
605
606 /* Note: These calls are spread out to insure that the return values
607 of the calls (which may be newly-created strings) are properly
608 GC-protected. */
609
610 GCPRO1 (dir);
611
612 dir = current_buffer->directory;
613 /* If the current dir has no terminating slash, we'll get undesirable
614 results, so put the slash back. */
615 dir = Ffile_name_as_directory (dir);
616 dir = Funhandled_file_name_directory (dir);
617 dir = expand_and_dir_to_file (dir, Qnil);
618
619 str = alloca_ibytes (XSTRING_LENGTH (dir) + 2);
620 len = XSTRING_LENGTH (dir);
621 memcpy (str, XSTRING_DATA (dir), len);
622 if (!IS_ANY_SEP (str[len - 1]))
623 str[len++] = DIRECTORY_SEP;
624 str[len] = 0;
625
626 if (sh == 0)
627 sh = egetenv ("SHELL");
628 if (sh == 0)
629 sh = (Ibyte *) "sh";
630
631 PATHNAME_CONVERT_OUT (sh, shext);
632
633 UNGCPRO;
634
635 #ifdef WIN32_NATIVE
636
637 if (str)
638 qxe_chdir (str);
639
640 /* Waits for process completion */
641 if (XEUNICODE_P ?
642 _wspawnlp (_P_WAIT, (const wchar_t *) shext,
643 (const wchar_t *) shext, NULL) != 0 :
644 _spawnlp (_P_WAIT, shext, shext, NULL) != 0)
645 report_process_error ("Can't spawn subshell", Qunbound);
646 else
647 return; /* we're done, no need to wait for termination */
648
649 #else /* not WIN32_NATIVE */
650
651 {
652 int pid;
653 struct save_signal saved_handlers[5];
654
655 saved_handlers[0].code = SIGINT;
656 saved_handlers[1].code = SIGQUIT;
657 saved_handlers[2].code = SIGTERM;
658 #ifdef SIGIO
659 saved_handlers[3].code = SIGIO;
660 saved_handlers[4].code = 0;
661 #else
662 saved_handlers[3].code = 0;
663 #endif
664
665 pid = fork ();
666
667 if (pid == -1)
668 report_process_error ("Can't spawn subshell", Qunbound);
669 if (pid == 0)
670 {
671 if (str)
672 qxe_chdir (str);
673
674 #if !defined (NO_SUBPROCESSES)
675 close_process_descs (); /* Close Emacs's pipes/ptys */
676 #endif
677
678 #ifdef SET_EMACS_PRIORITY
679 if (emacs_priority != 0)
680 nice (-emacs_priority); /* Give the new shell the default priority */
681 #endif
682
683 execlp (shext, shext, 0);
684 retry_write (1, "Can't execute subshell", 22);
685 _exit (1);
686 }
687
688 save_signal_handlers (saved_handlers);
689 synch_process_alive = 1;
690 wait_for_termination (pid);
691 restore_signal_handlers (saved_handlers);
692 }
693
694 #endif /* not WIN32_NATIVE */
695 }
696
697 #endif /* !defined (SIGTSTP) && !defined (USG_JOBCTRL) */
698 557
699 558
700 559
701 /* Suspend the Emacs process; give terminal to its superior. */ 560 /* Suspend the Emacs process; give terminal to its superior. */
702 void 561 void
706 { 565 {
707 int pgrp = EMACS_GET_PROCESS_GROUP (); 566 int pgrp = EMACS_GET_PROCESS_GROUP ();
708 EMACS_KILLPG (pgrp, SIGTSTP); 567 EMACS_KILLPG (pgrp, SIGTSTP);
709 } 568 }
710 569
711 #elif defined (USG_JOBCTRL) 570 #else /* No SIGTSTP */
712 /* If you don't know what this is don't mess with it */ 571 /* If you don't know what this is don't mess with it */
713 ptrace (0, 0, 0, 0); /* set for ptrace - caught by csh */ 572 ptrace (0, 0, 0, 0); /* set for ptrace - caught by csh */
714 kill (getpid (), SIGQUIT); 573 kill (getpid (), SIGQUIT);
715
716 #else /* No SIGTSTP or USG_JOBCTRL */
717
718 /* On a system where suspending is not implemented,
719 instead fork a subshell and let it talk directly to the terminal
720 while we wait. */
721 sys_subshell ();
722
723 #endif 574 #endif
724 } 575 }
725 576
726 /* Suspend a process if possible; give terminal to its superior. */ 577 /* Suspend a process if possible; give terminal to its superior. */
727 void 578 void
732 int UNUSED (process) 583 int UNUSED (process)
733 #endif 584 #endif
734 ) 585 )
735 { 586 {
736 /* I don't doubt that it is possible to suspend processes on 587 /* I don't doubt that it is possible to suspend processes on
737 * VMS machines or thost that use USG_JOBCTRL, 588 * VMS machines, but I don't know how to do it, so...
738 * but I don't know how to do it, so...
739 */ 589 */
740 #if defined (SIGTSTP) 590 #if defined (SIGTSTP)
741 kill(process, SIGTSTP); 591 kill(process, SIGTSTP);
742 #endif 592 #endif
743 } 593 }
883 #else 733 #else
884 int UNUSED (fd) 734 int UNUSED (fd)
885 #endif 735 #endif
886 ) 736 )
887 { 737 {
888 #ifdef IBMRTAIX
889 /* On AIX, the parent gets SIGHUP when a pty attached child dies. So, we */
890 /* ignore SIGHUP once we've started a child on a pty. Note that this may */
891 /* cause EMACS not to die when it should, i.e., when its own controlling */
892 /* tty goes away. I've complained to the AIX developers, and they may */
893 /* change this behavior, but I'm not going to hold my breath. */
894 EMACS_SIGNAL (SIGHUP, SIG_IGN);
895 #endif /* IBMRTAIX */
896
897 #ifdef TIOCPKT 738 #ifdef TIOCPKT
898 /* In some systems (Linux through 2.0.0, at least), packet mode doesn't 739 /* In some systems (Linux through 2.0.0, at least), packet mode doesn't
899 get cleared when a pty is closed, so we need to clear it here. 740 get cleared when a pty is closed, so we need to clear it here.
900 Linux pre2.0.13 contained an attempted fix for this (from Ted Ts'o, 741 Linux pre2.0.13 contained an attempted fix for this (from Ted Ts'o,
901 tytso@mit.edu), but apparently it messed up rlogind and telnetd, so he 742 tytso@mit.edu), but apparently it messed up rlogind and telnetd, so he
939 struct termios sg; 780 struct termios sg;
940 781
941 sg.c_cflag = B9600; 782 sg.c_cflag = B9600;
942 tcgetattr (input_fd, &sg); 783 tcgetattr (input_fd, &sg);
943 DEVICE_TTY_DATA (d)->ospeed = cfgetospeed (&sg); 784 DEVICE_TTY_DATA (d)->ospeed = cfgetospeed (&sg);
944 # if defined (USE_GETOBAUD) && defined (getobaud)
945 /* m88k-motorola-sysv3 needs this (ghazi@noc.rutgers.edu) 9/1/94. */
946 if (DEVICE_TTY_DATA (d)->ospeed == 0)
947 DEVICE_TTY_DATA (d)->ospeed = getobaud (sg.c_cflag);
948 # endif
949 #elif defined (HAVE_TERMIO) 785 #elif defined (HAVE_TERMIO)
950 struct termio sg; 786 struct termio sg;
951 787
952 sg.c_cflag = B9600; 788 sg.c_cflag = B9600;
953 # ifdef HAVE_TCATTR 789 # ifdef HAVE_TCATTR
1007 } 843 }
1008 #endif 844 #endif
1009 } 845 }
1010 #elif defined (F_SETOWN) && !defined (F_SETOWN_BUG) 846 #elif defined (F_SETOWN) && !defined (F_SETOWN_BUG)
1011 DEVICE_OLD_FCNTL_OWNER (d) = fcntl (filedesc, F_GETOWN, 0); 847 DEVICE_OLD_FCNTL_OWNER (d) = fcntl (filedesc, F_GETOWN, 0);
1012 # ifdef F_SETOWN_SOCK_NEG
1013 /* stdin is a socket here */
1014 fcntl (filedesc, F_SETOWN, -getpid ());
1015 # else
1016 fcntl (filedesc, F_SETOWN, getpid ()); 848 fcntl (filedesc, F_SETOWN, getpid ());
1017 # endif
1018 #endif 849 #endif
1019 } 850 }
1020 851
1021 static void 852 static void
1022 reset_sigio_on_device (struct device *d) 853 reset_sigio_on_device (struct device *d)
1067 898
1068 But it appears that Linux also supports O_ASYNC, so I see no 899 But it appears that Linux also supports O_ASYNC, so I see no
1069 particular need to switch. --ben 900 particular need to switch. --ben
1070 */ 901 */
1071 902
1072 #if defined (I_SETSIG) && !defined (HPUX10) && !defined (LINUX) 903 #if defined (I_SETSIG) && !defined (HPUX11) && !defined (LINUX)
1073 { 904 {
1074 int events = 0; 905 int events = 0;
1075 ioctl (filedesc, I_GETSIG, &events); 906 ioctl (filedesc, I_GETSIG, &events);
1076 ioctl (filedesc, I_SETSIG, events | S_INPUT); 907 ioctl (filedesc, I_SETSIG, events | S_INPUT);
1077 } 908 }
1107 { 938 {
1108 int on = 1; 939 int on = 1;
1109 ioctl (filedesc, FIOASYNC, &on); 940 ioctl (filedesc, FIOASYNC, &on);
1110 } 941 }
1111 #endif 942 #endif
1112
1113 #if defined (_CX_UX) /* #### Is this crap necessary? */
1114 EMACS_UNBLOCK_SIGNAL (SIGIO);
1115 #endif
1116 } 943 }
1117 944
1118 static void 945 static void
1119 unrequest_sigio_on_device (struct device *d) 946 unrequest_sigio_on_device (struct device *d)
1120 { 947 {
1121 int filedesc = DEVICE_INFD (d); 948 int filedesc = DEVICE_INFD (d);
1122 949
1123 #if defined (I_SETSIG) && !defined (HPUX10) && !defined (LINUX) 950 #if defined (I_SETSIG) && !defined (HPUX11) && !defined (LINUX)
1124 { 951 {
1125 int events = 0; 952 int events = 0;
1126 ioctl (filedesc, I_GETSIG, &events); 953 ioctl (filedesc, I_GETSIG, &events);
1127 ioctl (filedesc, I_SETSIG, events & ~S_INPUT); 954 ioctl (filedesc, I_SETSIG, events & ~S_INPUT);
1128 } 955 }
1463 /* Get the current settings, and see if they're what we asked for. */ 1290 /* Get the current settings, and see if they're what we asked for. */
1464 tcgetattr (fd, &new_); 1291 tcgetattr (fd, &new_);
1465 /* We cannot use memcmp on the whole structure here because under 1292 /* We cannot use memcmp on the whole structure here because under
1466 * aix386 the termios structure has some reserved field that may 1293 * aix386 the termios structure has some reserved field that may
1467 * not be filled in. 1294 * not be filled in.
1295 * FIXME: Now that aix386 is gone, can we memcmp the whole structure?
1468 */ 1296 */
1469 if ( new_.c_iflag == settings->main.c_iflag 1297 if ( new_.c_iflag == settings->main.c_iflag
1470 && new_.c_oflag == settings->main.c_oflag 1298 && new_.c_oflag == settings->main.c_oflag
1471 && new_.c_cflag == settings->main.c_cflag 1299 && new_.c_cflag == settings->main.c_cflag
1472 && new_.c_lflag == settings->main.c_lflag 1300 && new_.c_lflag == settings->main.c_lflag
1509 /* Initializing a device */ 1337 /* Initializing a device */
1510 /* ------------------------------------------------------ */ 1338 /* ------------------------------------------------------ */
1511 1339
1512 #ifdef HAVE_TTY 1340 #ifdef HAVE_TTY
1513 1341
1514 /* This may also be defined in stdio,
1515 but if so, this does no harm,
1516 and using the same name avoids wasting the other one's space. */
1517
1518 #if ((defined(USG) || defined(DGUX)) && !defined(__STDC__))
1519 char _sobuf[BUFSIZ+8];
1520 #elif (defined(USG) && !defined(LINUX) && !defined(_SCO_DS)) || defined(IRIX5)
1521 extern unsigned char _sobuf[BUFSIZ+8];
1522 #else
1523 char _sobuf[BUFSIZ];
1524 #endif
1525
1526 #if defined (TIOCGLTC) && defined (HAVE_LTCHARS) /* HAVE_LTCHARS */ 1342 #if defined (TIOCGLTC) && defined (HAVE_LTCHARS) /* HAVE_LTCHARS */
1527 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1}; 1343 static struct ltchars new_ltchars = {-1,-1,-1,-1,-1,-1};
1528 #endif 1344 #endif
1529 #ifdef TIOCGETC /* HAVE_TCHARS */ 1345 #ifdef TIOCGETC /* HAVE_TCHARS */
1530 #ifdef HAVE_TCHARS 1346 #ifdef HAVE_TCHARS
1535 static void 1351 static void
1536 tty_init_sys_modes_on_device (struct device *d) 1352 tty_init_sys_modes_on_device (struct device *d)
1537 { 1353 {
1538 struct emacs_tty tty; 1354 struct emacs_tty tty;
1539 int input_fd; 1355 int input_fd;
1540 #if defined (IBMR2AIX) && defined (AIXHFT)
1541 int output_fd;
1542 #endif
1543 struct console *con = XCONSOLE (DEVICE_CONSOLE (d)); 1356 struct console *con = XCONSOLE (DEVICE_CONSOLE (d));
1544 1357
1545 input_fd = CONSOLE_TTY_DATA (con)->infd; 1358 input_fd = CONSOLE_TTY_DATA (con)->infd;
1546 #if defined (IBMR2AIX) && defined (AIXHFT)
1547 output_fd = CONSOLE_TTY_DATA (con)->outfd;
1548 #endif
1549 1359
1550 emacs_get_tty (input_fd, &CONSOLE_TTY_DATA (con)->old_tty); 1360 emacs_get_tty (input_fd, &CONSOLE_TTY_DATA (con)->old_tty);
1551 tty = CONSOLE_TTY_DATA (con)->old_tty; 1361 tty = CONSOLE_TTY_DATA (con)->old_tty;
1552 1362
1553 con->tty_erase_char = Qnil; 1363 con->tty_erase_char = Qnil;
1554 1364
1555 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS) 1365 #if defined (HAVE_TERMIO) || defined (HAVE_TERMIOS)
1556 /* after all those years... */ 1366 /* after all those years... */
1557 con->tty_erase_char = make_char (tty.main.c_cc[VERASE]); 1367 con->tty_erase_char = make_char (tty.main.c_cc[VERASE]);
1558 #ifdef DGUX
1559 /* This allows meta to be sent on 8th bit. */
1560 tty.main.c_iflag &= ~INPCK; /* don't check input for parity */
1561 #endif
1562 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */ 1368 tty.main.c_iflag |= (IGNBRK); /* Ignore break condition */
1563 tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */ 1369 tty.main.c_iflag &= ~ICRNL; /* Disable map of CR to NL on input */
1564 #ifdef ISTRIP 1370 #ifdef ISTRIP
1565 tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */ 1371 tty.main.c_iflag &= ~ISTRIP; /* don't strip 8th bit on input */
1566 #endif 1372 #endif
1651 tty.main.c_cc[VSTRT] = _POSIX_VDISABLE; /* called VSTRT on some systems */ 1457 tty.main.c_cc[VSTRT] = _POSIX_VDISABLE; /* called VSTRT on some systems */
1652 #endif /* VSTART */ 1458 #endif /* VSTART */
1653 #ifdef VSTOP 1459 #ifdef VSTOP
1654 tty.main.c_cc[VSTOP] = _POSIX_VDISABLE; 1460 tty.main.c_cc[VSTOP] = _POSIX_VDISABLE;
1655 #endif /* VSTOP */ 1461 #endif /* VSTOP */
1656 #ifdef SET_LINE_DISCIPLINE
1657 /* Need to explicitly request TERMIODISC line discipline or
1658 Ultrix's termios does not work correctly. */
1659 tty.main.c_line = SET_LINE_DISCIPLINE;
1660 #endif
1661 1462
1662 #ifdef AIX 1463 #ifdef AIX
1663 #ifndef IBMR2AIX 1464 #ifndef IBMR2AIX
1664 /* AIX enhanced edit loses NULs, so disable it. */ 1465 /* AIX enhanced edit loses NULs, so disable it. */
1665 tty.main.c_line = 0; 1466 tty.main.c_line = 0;
1703 tty.tchars.t_stopc = '\023'; 1504 tty.tchars.t_stopc = '\023';
1704 } 1505 }
1705 1506
1706 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH | 1507 tty.lmode = LDECCTQ | LLITOUT | LPASS8 | LNOFLSH |
1707 CONSOLE_TTY_DATA (con)->old_tty.lmode; 1508 CONSOLE_TTY_DATA (con)->old_tty.lmode;
1708
1709 #if defined (ultrix) || defined (__bsdi__)
1710 /* Under Ultrix 4.2a, leaving this out doesn't seem to hurt
1711 anything, and leaving it in breaks the meta key. Go figure. */
1712 /* Turning off ONLCR is enough under BSD/386. Leave the general
1713 output post-processing flag alone since for some reason it
1714 doesn't get reset after XEmacs goes away. */
1715 tty.lmode &= ~LLITOUT;
1716 #endif
1717
1718 #endif /* HAVE_TCHARS */ 1509 #endif /* HAVE_TCHARS */
1719 #endif /* not HAVE_TERMIO */ 1510 #endif /* not HAVE_TERMIO */
1720 1511
1721 #ifdef HAVE_LTCHARS 1512 #ifdef HAVE_LTCHARS
1722 tty.ltchars = new_ltchars; 1513 tty.ltchars = new_ltchars;
1732 #endif 1523 #endif
1733 #ifdef TIOCSTART 1524 #ifdef TIOCSTART
1734 if (!TTY_FLAGS (con).flow_control) ioctl (input_fd, TIOCSTART, 0); 1525 if (!TTY_FLAGS (con).flow_control) ioctl (input_fd, TIOCSTART, 0);
1735 #endif 1526 #endif
1736 1527
1737 #if defined (HAVE_TERMIOS) || defined (HPUX9) 1528 #if defined (HAVE_TERMIOS)
1738 #ifdef TCOON 1529 #ifdef TCOON
1739 if (!TTY_FLAGS (con).flow_control) tcflow (input_fd, TCOON); 1530 if (!TTY_FLAGS (con).flow_control) tcflow (input_fd, TCOON);
1740 #endif 1531 #endif
1741 #endif 1532 #endif
1742 #ifdef AIXHFT 1533
1743 hft_init (con);
1744 #ifdef IBMR2AIX
1745 {
1746 /* IBM's HFT device usually thinks a ^J should be LF/CR.
1747 We need it to be only LF. This is the way that is
1748 done. */
1749 struct termio tty;
1750
1751 if (ioctl (output_fd, HFTGETID, &tty) != -1)
1752 retry_write (output_fd, "\033[20l", 5);
1753 }
1754 #endif
1755 #endif
1756
1757 #if 0 /* We do our own buffering with lstreams. */
1758 #ifdef _IOFBF
1759 /* This symbol is defined on recent USG systems.
1760 Someone says without this call USG won't really buffer the file
1761 even with a call to setbuf. */
1762 setvbuf (CONSOLE_TTY_DATA (con)->outfd, (char *) _sobuf, _IOFBF,
1763 sizeof (_sobuf));
1764 #else
1765 setbuf (CONSOLE_TTY_DATA (con)->outfd, (char *) _sobuf);
1766 #endif
1767 #endif
1768 set_tty_modes (con); 1534 set_tty_modes (con);
1769 } 1535 }
1770 1536
1771 #endif /* HAVE_TTY */ 1537 #endif /* HAVE_TTY */
1772 1538
1929 /* Prepare the terminal for exiting Emacs; move the cursor to the 1695 /* Prepare the terminal for exiting Emacs; move the cursor to the
1930 bottom of the frame, turn off interrupt-driven I/O, etc. */ 1696 bottom of the frame, turn off interrupt-driven I/O, etc. */
1931 static void 1697 static void
1932 tty_reset_sys_modes_on_device (struct device *d) 1698 tty_reset_sys_modes_on_device (struct device *d)
1933 { 1699 {
1934 #if defined (BSD) || (defined (IBMR2AIX) && defined (AIXHFT)) 1700 #if defined (BSD)
1935 int output_fd; 1701 int output_fd;
1936 #endif 1702 #endif
1937 int input_fd; 1703 int input_fd;
1938 struct console *con = XCONSOLE (DEVICE_CONSOLE (d)); 1704 struct console *con = XCONSOLE (DEVICE_CONSOLE (d));
1939 1705
1940 input_fd = CONSOLE_TTY_DATA (con)->infd; 1706 input_fd = CONSOLE_TTY_DATA (con)->infd;
1941 #if defined (BSD) || (defined (IBMR2AIX) && defined (AIXHFT)) 1707 #if defined (BSD)
1942 output_fd = CONSOLE_TTY_DATA (con)->outfd; 1708 output_fd = CONSOLE_TTY_DATA (con)->outfd;
1943 #endif
1944
1945 #if defined (IBMR2AIX) && defined (AIXHFT)
1946 {
1947 /* HFT consoles normally use ^J as a LF/CR. We forced it to
1948 do the LF only. Now, we need to reset it. */
1949 struct termio tty;
1950
1951 if (ioctl (output_fd, HFTGETID, &tty) != -1)
1952 retry_write (output_fd, "\033[20h", 5);
1953 }
1954 #endif 1709 #endif
1955 1710
1956 tty_redisplay_shutdown (con); 1711 tty_redisplay_shutdown (con);
1957 /* reset_tty_modes() flushes the connection at its end. */ 1712 /* reset_tty_modes() flushes the connection at its end. */
1958 reset_tty_modes (con); 1713 reset_tty_modes (con);
1963 #endif 1718 #endif
1964 1719
1965 while (emacs_set_tty (input_fd, &CONSOLE_TTY_DATA (con)->old_tty, 0) 1720 while (emacs_set_tty (input_fd, &CONSOLE_TTY_DATA (con)->old_tty, 0)
1966 < 0 && errno == EINTR) 1721 < 0 && errno == EINTR)
1967 ; 1722 ;
1968
1969 #ifdef SET_LINE_DISCIPLINE
1970 /* Ultrix's termios *ignores* any line discipline except TERMIODISC.
1971 A different old line discipline is therefore not restored, yet.
1972 Restore the old line discipline by hand. */
1973 ioctl (input_fd, TIOCSETD, &old_tty.main.c_line);
1974 #endif
1975
1976 #ifdef AIXHFT
1977 hft_reset (con);
1978 #endif
1979
1980 } 1723 }
1981 1724
1982 #endif /* HAVE_TTY */ 1725 #endif /* HAVE_TTY */
1983 1726
1984 void 1727 void
2036 if (CONSOLEP (Vcontrolling_terminal) && 1779 if (CONSOLEP (Vcontrolling_terminal) &&
2037 CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal))) 1780 CONSOLE_LIVE_P (XCONSOLE (Vcontrolling_terminal)))
2038 reset_one_console (XCONSOLE (Vcontrolling_terminal)); 1781 reset_one_console (XCONSOLE (Vcontrolling_terminal));
2039 unmunge_process_groups (); 1782 unmunge_process_groups ();
2040 } 1783 }
2041
2042
2043 /* ------------------------------------------------------ */
2044 /* extra TTY stuff under AIX */
2045 /* ------------------------------------------------------ */
2046
2047 #ifdef AIXHFT
2048
2049 /* Called from init_sys_modes. */
2050 static void
2051 hft_init (struct console *con)
2052 {
2053 int junk;
2054 int input_fd;
2055
2056 assert (CONSOLE_TTY_P (con));
2057 input_fd = CONSOLE_TTY_DATA (con)->infd;
2058
2059 /* If we're not on an HFT we shouldn't do any of this. We determine
2060 if we are on an HFT by trying to get an HFT error code. If this
2061 call fails, we're not on an HFT. */
2062 #ifdef IBMR2AIX
2063 if (ioctl (input_fd, HFQERROR, &junk) < 0)
2064 return;
2065 #else /* not IBMR2AIX */
2066 if (ioctl (input_fd, HFQEIO, 0) < 0)
2067 return;
2068 #endif /* not IBMR2AIX */
2069
2070 /* On AIX the default hft keyboard mapping uses backspace rather than delete
2071 as the rubout key's ASCII code. Here this is changed. The bug is that
2072 there's no way to determine the old mapping, so in reset_one_console
2073 we need to assume that the normal map had been present. Of course, this
2074 code also doesn't help if on a terminal emulator which doesn't understand
2075 HFT VTD's. */
2076 {
2077 struct hfbuf buf;
2078 struct hfkeymap keymap;
2079
2080 buf.hf_bufp = (char *)&keymap;
2081 buf.hf_buflen = sizeof (keymap);
2082 keymap.hf_nkeys = 2;
2083 keymap.hfkey[0].hf_kpos = 15;
2084 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE;
2085 #ifdef IBMR2AIX
2086 keymap.hfkey[0].hf_keyidh = '<';
2087 #else /* not IBMR2AIX */
2088 keymap.hfkey[0].hf_page = '<';
2089 #endif /* not IBMR2AIX */
2090 keymap.hfkey[0].hf_char = 127;
2091 keymap.hfkey[1].hf_kpos = 15;
2092 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT;
2093 #ifdef IBMR2AIX
2094 keymap.hfkey[1].hf_keyidh = '<';
2095 #else /* not IBMR2AIX */
2096 keymap.hfkey[1].hf_page = '<';
2097 #endif /* not IBMR2AIX */
2098 keymap.hfkey[1].hf_char = 127;
2099 hftctl (input_fd, HFSKBD, &buf);
2100 }
2101 /* #### Should probably set a console TTY flag here. */
2102 #if 0
2103 /* The HFT system on AIX doesn't optimize for scrolling, so it's really ugly
2104 at times. */
2105 line_ins_del_ok = char_ins_del_ok = 0;
2106 #endif /* 0 */
2107 }
2108
2109 /* Reset the rubout key to backspace. */
2110
2111 static void
2112 hft_reset (struct console *con)
2113 {
2114 struct hfbuf buf;
2115 struct hfkeymap keymap;
2116 int junk;
2117 int input_fd;
2118
2119 assert (CONSOLE_TTY_P (con));
2120 input_fd = CONSOLE_TTY_DATA (con)->infd;
2121
2122 #ifdef IBMR2AIX
2123 if (ioctl (input_fd, HFQERROR, &junk) < 0)
2124 return;
2125 #else /* not IBMR2AIX */
2126 if (ioctl (input_fd, HFQEIO, 0) < 0)
2127 return;
2128 #endif /* not IBMR2AIX */
2129
2130 buf.hf_bufp = (char *)&keymap;
2131 buf.hf_buflen = sizeof (keymap);
2132 keymap.hf_nkeys = 2;
2133 keymap.hfkey[0].hf_kpos = 15;
2134 keymap.hfkey[0].hf_kstate = HFMAPCHAR | HFSHFNONE;
2135 #ifdef IBMR2AIX
2136 keymap.hfkey[0].hf_keyidh = '<';
2137 #else /* not IBMR2AIX */
2138 keymap.hfkey[0].hf_page = '<';
2139 #endif /* not IBMR2AIX */
2140 keymap.hfkey[0].hf_char = 8;
2141 keymap.hfkey[1].hf_kpos = 15;
2142 keymap.hfkey[1].hf_kstate = HFMAPCHAR | HFSHFSHFT;
2143 #ifdef IBMR2AIX
2144 keymap.hfkey[1].hf_keyidh = '<';
2145 #else /* not IBMR2AIX */
2146 keymap.hfkey[1].hf_page = '<';
2147 #endif /* not IBMR2AIX */
2148 keymap.hfkey[1].hf_char = 8;
2149 hftctl (input_fd, HFSKBD, &buf);
2150 }
2151
2152 #endif /* AIXHFT */
2153 1784
2154 1785
2155 /************************************************************************/ 1786 /************************************************************************/
2156 /* limits of text/data segments */ 1787 /* limits of text/data segments */
2157 /************************************************************************/ 1788 /************************************************************************/
2444 #### Another possibility is to just longjmp() out of the signal 2075 #### Another possibility is to just longjmp() out of the signal
2445 handler. According to W.R. Stevens, this should be OK on all 2076 handler. According to W.R. Stevens, this should be OK on all
2446 systems. However, I don't want to deal with the potential 2077 systems. However, I don't want to deal with the potential
2447 evil ramifications of this at this point. */ 2078 evil ramifications of this at this point. */
2448 2079
2449 #ifdef DGUX
2450 /* This gets us restartable system calls for efficiency.
2451 The "else" code will work as well. */
2452 return (berk_signal (signal_number, action));
2453 #else
2454 sigemptyset (&new_action.sa_mask); 2080 sigemptyset (&new_action.sa_mask);
2455 new_action.sa_handler = action; 2081 new_action.sa_handler = action;
2456 #if defined (SA_RESTART) 2082 #if defined (SA_RESTART)
2457 /* Emacs mostly works better with restartable system services. If this 2083 /* Emacs mostly works better with restartable system services. If this
2458 * flag exists, we probably want to turn it on here. 2084 * flag exists, we probably want to turn it on here.
2461 #else 2087 #else
2462 new_action.sa_flags = 0; 2088 new_action.sa_flags = 0;
2463 #endif 2089 #endif
2464 sigaction (signal_number, &new_action, &old_action); 2090 sigaction (signal_number, &new_action, &old_action);
2465 return (old_action.sa_handler); 2091 return (old_action.sa_handler);
2466 #endif /* DGUX */
2467 2092
2468 #else /* not 0 */ 2093 #else /* not 0 */
2469 2094
2470 sigemptyset (&new_action.sa_mask); 2095 sigemptyset (&new_action.sa_mask);
2471 new_action.sa_handler = action; 2096 new_action.sa_handler = action;
2509 /* Emulation of strerror() and errno support */ 2134 /* Emulation of strerror() and errno support */
2510 /************************************************************************/ 2135 /************************************************************************/
2511 2136
2512 #ifndef HAVE_STRERROR 2137 #ifndef HAVE_STRERROR
2513 2138
2514 #if !defined(NeXT) && !defined(__alpha) && !defined(MACH) && !defined(LINUX) && !defined(IRIX) && !defined(__NetBSD__) 2139 #if !defined(__alpha) && !defined(MACH) && !defined(LINUX) && !defined(IRIX) && !defined(__NetBSD__)
2515 /* Linux added here by Raymond L. Toy <toy@alydar.crd.ge.com> for XEmacs. */ 2140 /* Linux added here by Raymond L. Toy <toy@alydar.crd.ge.com> for XEmacs. */
2516 /* Irix added here by gparker@sni-usa.com for XEmacs. */ 2141 /* Irix added here by gparker@sni-usa.com for XEmacs. */
2517 /* NetBSD added here by James R Grinter <jrg@doc.ic.ac.uk> for XEmacs */ 2142 /* NetBSD added here by James R Grinter <jrg@doc.ic.ac.uk> for XEmacs */
2518 extern const char *sys_errlist[]; 2143 extern const char *sys_errlist[];
2519 extern int sys_nerr; 2144 extern int sys_nerr;
3898 DEFER_GETTEXT ("bogus signal"), /* 23 */ 3523 DEFER_GETTEXT ("bogus signal"), /* 23 */
3899 DEFER_GETTEXT ("bogus signal"), /* 24 */ 3524 DEFER_GETTEXT ("bogus signal"), /* 24 */
3900 DEFER_GETTEXT ("LAN I/O interrupt"), /* 25 SIGAIO */ 3525 DEFER_GETTEXT ("LAN I/O interrupt"), /* 25 SIGAIO */
3901 DEFER_GETTEXT ("PTY I/O interrupt"), /* 26 SIGPTY */ 3526 DEFER_GETTEXT ("PTY I/O interrupt"), /* 26 SIGPTY */
3902 DEFER_GETTEXT ("I/O intervention required"), /* 27 SIGIOINT */ 3527 DEFER_GETTEXT ("I/O intervention required"), /* 27 SIGIOINT */
3903 #ifdef AIXHFT
3904 "HFT grant", /* 28 SIGGRANT */
3905 "HFT retract", /* 29 SIGRETRACT */
3906 "HFT sound done", /* 30 SIGSOUND */
3907 "HFT input ready", /* 31 SIGMSG */
3908 #endif
3909 /* $$####end-snarf */ 3528 /* $$####end-snarf */
3910 0 3529 0
3911 }; 3530 };
3912 #else /* USG, not AIX */ 3531 #else /* USG, not AIX */
3913 const char *sys_siglist[NSIG + 1] = 3532 const char *sys_siglist[NSIG + 1] =
3957 /* $$####end-snarf */ 3576 /* $$####end-snarf */
3958 0 3577 0
3959 }; 3578 };
3960 #endif /* not AIX */ 3579 #endif /* not AIX */
3961 #endif /* USG */ 3580 #endif /* USG */
3962 #ifdef DGUX
3963 const char *sys_siglist[NSIG + 1] =
3964 {
3965 /* $$####begin-snarf */
3966 "null signal", /* 0 SIGNULL */
3967 "hangup", /* 1 SIGHUP */
3968 "interrupt", /* 2 SIGINT */
3969 "quit", /* 3 SIGQUIT */
3970 "illegal instruction", /* 4 SIGILL */
3971 "trace trap", /* 5 SIGTRAP */
3972 "abort termination", /* 6 SIGABRT */
3973 "SIGEMT", /* 7 SIGEMT */
3974 "floating point exception", /* 8 SIGFPE */
3975 "kill", /* 9 SIGKILL */
3976 "bus error", /* 10 SIGBUS */
3977 "segmentation violation", /* 11 SIGSEGV */
3978 "bad argument to system call", /* 12 SIGSYS */
3979 "write on a pipe with no reader", /* 13 SIGPIPE */
3980 "alarm clock", /* 14 SIGALRM */
3981 "software termination signal", /* 15 SIGTERM */
3982 "user defined signal 1", /* 16 SIGUSR1 */
3983 "user defined signal 2", /* 17 SIGUSR2 */
3984 "child stopped or terminated", /* 18 SIGCLD */
3985 "power-fail restart", /* 19 SIGPWR */
3986 "window size changed", /* 20 SIGWINCH */
3987 "undefined", /* 21 */
3988 "pollable event occurred", /* 22 SIGPOLL */
3989 "sendable stop signal not from tty", /* 23 SIGSTOP */
3990 "stop signal from tty", /* 24 SIGSTP */
3991 "continue a stopped process", /* 25 SIGCONT */
3992 "attempted background tty read", /* 26 SIGTTIN */
3993 "attempted background tty write", /* 27 SIGTTOU */
3994 "undefined", /* 28 */
3995 "undefined", /* 29 */
3996 "undefined", /* 30 */
3997 "undefined", /* 31 */
3998 "undefined", /* 32 */
3999 "socket (TCP/IP) urgent data arrival", /* 33 SIGURG */
4000 "I/O is possible", /* 34 SIGIO */
4001 "exceeded cpu time limit", /* 35 SIGXCPU */
4002 "exceeded file size limit", /* 36 SIGXFSZ */
4003 "virtual time alarm", /* 37 SIGVTALRM */
4004 "profiling time alarm", /* 38 SIGPROF */
4005 "undefined", /* 39 */
4006 "file record locks revoked", /* 40 SIGLOST */
4007 "undefined", /* 41 */
4008 "undefined", /* 42 */
4009 "undefined", /* 43 */
4010 "undefined", /* 44 */
4011 "undefined", /* 45 */
4012 "undefined", /* 46 */
4013 "undefined", /* 47 */
4014 "undefined", /* 48 */
4015 "undefined", /* 49 */
4016 "undefined", /* 50 */
4017 "undefined", /* 51 */
4018 "undefined", /* 52 */
4019 "undefined", /* 53 */
4020 "undefined", /* 54 */
4021 "undefined", /* 55 */
4022 "undefined", /* 56 */
4023 "undefined", /* 57 */
4024 "undefined", /* 58 */
4025 "undefined", /* 59 */
4026 "undefined", /* 60 */
4027 "undefined", /* 61 */
4028 "undefined", /* 62 */
4029 "undefined", /* 63 */
4030 "notification message in mess. queue", /* 64 SIGDGNOTIFY */
4031 /* $$####end-snarf */
4032 0
4033 };
4034 #endif /* DGUX */
4035 3581
4036 #endif /* (!defined(HAVE_DECL_SYS_SIGLIST) || !HAVE_DECL_SYS_SIGLIST ) && !defined (HAVE_SYS_SIGLIST) */ 3582 #endif /* (!defined(HAVE_DECL_SYS_SIGLIST) || !HAVE_DECL_SYS_SIGLIST ) && !defined (HAVE_SYS_SIGLIST) */
4037 3583
4038 3584
4039 /************************************************************************/ 3585 /************************************************************************/
4042 3588
4043 #ifdef SYSV_SYSTEM_DIR 3589 #ifdef SYSV_SYSTEM_DIR
4044 3590
4045 #include <dirent.h> 3591 #include <dirent.h>
4046 3592
4047 #if defined(BROKEN_CLOSEDIR) || !defined(HAVE_CLOSEDIR) 3593 #if !defined(HAVE_CLOSEDIR)
4048 int 3594 int
4049 closedir (DIR *dirp) /* stream from opendir */ 3595 closedir (DIR *dirp) /* stream from opendir */
4050 { 3596 {
4051 int rtnval; 3597 int rtnval;
4052 3598
4059 xfree (dirp->dd_buf, char *); /* directory block defined in <dirent.h> */ 3605 xfree (dirp->dd_buf, char *); /* directory block defined in <dirent.h> */
4060 #endif 3606 #endif
4061 xfree (dirp, DIR *); 3607 xfree (dirp, DIR *);
4062 return (rtnval); 3608 return (rtnval);
4063 } 3609 }
4064 #endif /* BROKEN_CLOSEDIR or not HAVE_CLOSEDIR */ 3610 #endif /* not HAVE_CLOSEDIR */
4065 #endif /* SYSV_SYSTEM_DIR */ 3611 #endif /* SYSV_SYSTEM_DIR */
4066 3612
4067 #ifdef NONSYSTEM_DIR_LIBRARY 3613 #ifdef NONSYSTEM_DIR_LIBRARY
4068 3614
4069 DIR * 3615 DIR *