Mercurial > hg > xemacs-beta
comparison src/process-unix.c @ 535:c69610198c35
[xemacs-hg @ 2001-05-14 04:52:02 by martinb]
Eliminate the need to define HAVE_PTYS in s&m files.
author | martinb |
---|---|
date | Mon, 14 May 2001 04:52:49 +0000 |
parents | 7039e6323819 |
children | ed498ef2108b |
comparison
equal
deleted
inserted
replaced
534:a0266879cecf | 535:c69610198c35 |
---|---|
196 event_stream_select_process (XPROCESS (proc)); | 196 event_stream_select_process (XPROCESS (proc)); |
197 | 197 |
198 return proc; | 198 return proc; |
199 } | 199 } |
200 | 200 |
201 #ifdef HAVE_PTYS | |
202 static int allocate_pty_the_old_fashioned_way (void); | 201 static int allocate_pty_the_old_fashioned_way (void); |
203 | 202 |
204 /* The file name of the (slave) pty opened by allocate_pty(). */ | 203 /* The file name of the (slave) pty opened by allocate_pty(). */ |
205 #ifndef MAX_PTYNAME_LEN | 204 #ifndef MAX_PTYNAME_LEN |
206 #define MAX_PTYNAME_LEN 64 | 205 #define MAX_PTYNAME_LEN 64 |
408 close (fd); | 407 close (fd); |
409 } | 408 } |
410 } /* iteration */ | 409 } /* iteration */ |
411 return -1; | 410 return -1; |
412 } | 411 } |
413 #endif /* HAVE_PTYS */ | |
414 | 412 |
415 static int | 413 static int |
416 create_bidirectional_pipe (int *inchannel, int *outchannel, | 414 create_bidirectional_pipe (int *inchannel, int *outchannel, |
417 volatile int *forkin, volatile int *forkout) | 415 volatile int *forkin, volatile int *forkout) |
418 { | 416 { |
852 /* Use volatile to protect variables from being clobbered by longjmp. */ | 850 /* Use volatile to protect variables from being clobbered by longjmp. */ |
853 volatile int forkin = -1; | 851 volatile int forkin = -1; |
854 volatile int forkout = -1; | 852 volatile int forkout = -1; |
855 volatile int pty_flag = 0; | 853 volatile int pty_flag = 0; |
856 | 854 |
857 #ifdef HAVE_PTYS | |
858 if (!NILP (Vprocess_connection_type)) | 855 if (!NILP (Vprocess_connection_type)) |
859 { | 856 { |
860 /* find a new pty, open the master side, return the opened | 857 /* find a new pty, open the master side, return the opened |
861 file handle, and store the name of the corresponding slave | 858 file handle, and store the name of the corresponding slave |
862 side in global variable pty_name. */ | 859 side in global variable pty_name. */ |
863 outchannel = inchannel = allocate_pty (); | 860 outchannel = inchannel = allocate_pty (); |
864 } | 861 } |
865 | 862 |
866 if (inchannel >= 0) | 863 if (inchannel >= 0) /* We successfully allocated a pty. */ |
867 { | 864 { |
868 /* You're "supposed" to now open the slave in the child. | 865 /* You're "supposed" to now open the slave in the child. |
869 On some systems, we can open it here; this allows for | 866 On some systems, we can open it here; this allows for |
870 better error checking. */ | 867 better error checking. */ |
871 #if !defined(USG) | 868 #if !defined(USG) |
882 goto io_failure; | 879 goto io_failure; |
883 #endif /* not USG */ | 880 #endif /* not USG */ |
884 UNIX_DATA(p)->pty_flag = pty_flag = 1; | 881 UNIX_DATA(p)->pty_flag = pty_flag = 1; |
885 } | 882 } |
886 else | 883 else |
887 #endif /* HAVE_PTYS */ | |
888 if (create_bidirectional_pipe (&inchannel, &outchannel, | 884 if (create_bidirectional_pipe (&inchannel, &outchannel, |
889 &forkin, &forkout) < 0) | 885 &forkin, &forkout) < 0) |
890 goto io_failure; | 886 goto io_failure; |
891 | 887 |
892 #if 0 | 888 #if 0 |
922 making the pty be the controlling terminal of the process. | 918 making the pty be the controlling terminal of the process. |
923 Also put us in our own process group. */ | 919 Also put us in our own process group. */ |
924 | 920 |
925 disconnect_controlling_terminal (); | 921 disconnect_controlling_terminal (); |
926 | 922 |
927 #ifdef HAVE_PTYS | |
928 if (pty_flag) | 923 if (pty_flag) |
929 { | 924 { |
930 /* Open the pty connection and make the pty's terminal | 925 /* Open the pty connection and make the pty's terminal |
931 our controlling terminal. | 926 our controlling terminal. |
932 | 927 |
1038 JV: This needs to be done ALWAYS as we might have inherited | 1033 JV: This needs to be done ALWAYS as we might have inherited |
1039 a SIG_IGN handling from our parent (nohup) and we are in new | 1034 a SIG_IGN handling from our parent (nohup) and we are in new |
1040 process group. | 1035 process group. |
1041 */ | 1036 */ |
1042 signal (SIGHUP, SIG_DFL); | 1037 signal (SIGHUP, SIG_DFL); |
1043 } | 1038 |
1044 | 1039 /* Set up the terminal characteristics of the pty. */ |
1045 if (pty_flag) | 1040 child_setup_tty (xforkout); |
1046 /* Set up the terminal characteristics of the pty. */ | 1041 } /* if (pty_flag) */ |
1047 child_setup_tty (xforkout); | 1042 |
1048 | |
1049 #endif /* HAVE_PTYS */ | |
1050 | 1043 |
1051 signal (SIGINT, SIG_DFL); | 1044 signal (SIGINT, SIG_DFL); |
1052 signal (SIGQUIT, SIG_DFL); | 1045 signal (SIGQUIT, SIG_DFL); |
1053 | 1046 |
1054 { | 1047 { |
1096 if (forkin >= 0) | 1089 if (forkin >= 0) |
1097 close_safely (forkin); | 1090 close_safely (forkin); |
1098 if (forkin != forkout && forkout >= 0) | 1091 if (forkin != forkout && forkout >= 0) |
1099 close (forkout); | 1092 close (forkout); |
1100 | 1093 |
1101 #ifdef HAVE_PTYS | 1094 UNIX_DATA (p)->tty_name = pty_flag ? build_string (pty_name) : Qnil; |
1102 if (pty_flag) | |
1103 UNIX_DATA (p)->tty_name = build_string (pty_name); | |
1104 else | |
1105 #endif | |
1106 UNIX_DATA (p)->tty_name = Qnil; | |
1107 | 1095 |
1108 /* Notice that SIGCHLD was not blocked. (This is not possible on | 1096 /* Notice that SIGCHLD was not blocked. (This is not possible on |
1109 some systems.) No biggie if SIGCHLD occurs right around the | 1097 some systems.) No biggie if SIGCHLD occurs right around the |
1110 time that this call happens, because SIGCHLD() does not actually | 1098 time that this call happens, because SIGCHLD() does not actually |
1111 deselect the process (that doesn't occur until the next time | 1099 deselect the process (that doesn't occur until the next time |