Mercurial > hg > xemacs-beta
comparison src/process.c @ 359:8e84bee8ddd0 r21-1-9
Import from CVS: tag r21-1-9
author | cvs |
---|---|
date | Mon, 13 Aug 2007 10:57:55 +0200 |
parents | e11d67e05968 |
children | cc15677e0335 |
comparison
equal
deleted
inserted
replaced
358:fed6e0f6a03a | 359:8e84bee8ddd0 |
---|---|
57 #include "systime.h" | 57 #include "systime.h" |
58 #include "syssignal.h" /* Always include before systty.h */ | 58 #include "syssignal.h" /* Always include before systty.h */ |
59 #include "systty.h" | 59 #include "systty.h" |
60 #include "syswait.h" | 60 #include "syswait.h" |
61 | 61 |
62 Lisp_Object Qprocessp; | 62 Lisp_Object Qprocessp, Qprocess_live_p; |
63 | 63 |
64 /* Process methods */ | 64 /* Process methods */ |
65 struct process_methods the_process_methods; | 65 struct process_methods the_process_methods; |
66 | 66 |
67 /* a process object is a network connection when its pid field a cons | 67 /* a process object is a network connection when its pid field a cons |
252 Return t if OBJECT is a process. | 252 Return t if OBJECT is a process. |
253 */ | 253 */ |
254 (obj)) | 254 (obj)) |
255 { | 255 { |
256 return PROCESSP (obj) ? Qt : Qnil; | 256 return PROCESSP (obj) ? Qt : Qnil; |
257 } | |
258 | |
259 DEFUN ("process-live-p", Fprocess_live_p, 1, 1, 0, /* | |
260 Return t if OBJECT is a process that is alive. | |
261 */ | |
262 (obj)) | |
263 { | |
264 return PROCESSP (obj) && PROCESS_LIVE_P (XPROCESS (obj)) ? Qt : Qnil; | |
257 } | 265 } |
258 | 266 |
259 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /* | 267 DEFUN ("process-list", Fprocess_list, 0, 0, 0, /* |
260 Return a list of all processes. | 268 Return a list of all processes. |
261 */ | 269 */ |
507 p->exit_code = 0; | 515 p->exit_code = 0; |
508 | 516 |
509 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir)); | 517 pid = PROCMETH (create_process, (p, argv, nargv, program, cur_dir)); |
510 | 518 |
511 p->pid = make_int (pid); | 519 p->pid = make_int (pid); |
512 if (!NILP(p->pipe_instream)) | 520 if (PROCESS_LIVE_P (p)) |
513 event_stream_select_process (p); | 521 event_stream_select_process (p); |
514 } | 522 } |
515 | 523 |
516 /* This function is the unwind_protect form for Fstart_process_internal. If | 524 /* This function is the unwind_protect form for Fstart_process_internal. If |
517 PROC doesn't have its pid set, then we know someone has signalled | 525 PROC doesn't have its pid set, then we know someone has signalled |
813 calls set the filter to t, we have to stop now. Return -1 rather | 821 calls set the filter to t, we have to stop now. Return -1 rather |
814 than 0 so execute_internal_event() doesn't close the process. | 822 than 0 so execute_internal_event() doesn't close the process. |
815 Really, the loop in execute_internal_event() should check itself | 823 Really, the loop in execute_internal_event() should check itself |
816 for a process-filter change, like in status_notify(); but the | 824 for a process-filter change, like in status_notify(); but the |
817 struct Lisp_Process is not exported outside of this file. */ | 825 struct Lisp_Process is not exported outside of this file. */ |
818 if (NILP(p->pipe_instream)) | 826 if (!PROCESS_LIVE_P (p)) |
819 return -1; /* already closed */ | 827 return -1; /* already closed */ |
820 | 828 |
821 if (!NILP (p->filter) && (p->filter_does_read)) | 829 if (!NILP (p->filter) && (p->filter_does_read)) |
822 { | 830 { |
823 Lisp_Object filter_result; | 831 Lisp_Object filter_result; |
1022 | 1030 |
1023 void | 1031 void |
1024 set_process_filter (Lisp_Object proc, Lisp_Object filter, int filter_does_read) | 1032 set_process_filter (Lisp_Object proc, Lisp_Object filter, int filter_does_read) |
1025 { | 1033 { |
1026 CHECK_PROCESS (proc); | 1034 CHECK_PROCESS (proc); |
1027 if (PROCESS_LIVE_P (proc)) { | 1035 if (PROCESS_LIVE_P (XPROCESS (proc))) { |
1028 if (EQ (filter, Qt)) | 1036 if (EQ (filter, Qt)) |
1029 event_stream_unselect_process (XPROCESS (proc)); | 1037 event_stream_unselect_process (XPROCESS (proc)); |
1030 else | 1038 else |
1031 event_stream_select_process (XPROCESS (proc)); | 1039 event_stream_select_process (XPROCESS (proc)); |
1032 } | 1040 } |
1111 Return PROCESS's input coding system. | 1119 Return PROCESS's input coding system. |
1112 */ | 1120 */ |
1113 (process)) | 1121 (process)) |
1114 { | 1122 { |
1115 process = get_process (process); | 1123 process = get_process (process); |
1124 CHECK_LIVE_PROCESS (process); | |
1116 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) ); | 1125 return decoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_instream) ); |
1117 } | 1126 } |
1118 | 1127 |
1119 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /* | 1128 DEFUN ("process-output-coding-system", Fprocess_output_coding_system, 1, 1, 0, /* |
1120 Return PROCESS's output coding system. | 1129 Return PROCESS's output coding system. |
1121 */ | 1130 */ |
1122 (process)) | 1131 (process)) |
1123 { | 1132 { |
1124 process = get_process (process); | 1133 process = get_process (process); |
1134 CHECK_LIVE_PROCESS (process); | |
1125 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream)); | 1135 return encoding_stream_coding_system (XLSTREAM (XPROCESS (process)->coding_outstream)); |
1126 } | 1136 } |
1127 | 1137 |
1128 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* | 1138 DEFUN ("process-coding-system", Fprocess_coding_system, 1, 1, 0, /* |
1129 Return a pair of coding-system for decoding and encoding of PROCESS. | 1139 Return a pair of coding-system for decoding and encoding of PROCESS. |
1130 */ | 1140 */ |
1131 (process)) | 1141 (process)) |
1132 { | 1142 { |
1133 process = get_process (process); | 1143 process = get_process (process); |
1144 CHECK_LIVE_PROCESS (process); | |
1134 return Fcons (decoding_stream_coding_system | 1145 return Fcons (decoding_stream_coding_system |
1135 (XLSTREAM (XPROCESS (process)->coding_instream)), | 1146 (XLSTREAM (XPROCESS (process)->coding_instream)), |
1136 encoding_stream_coding_system | 1147 encoding_stream_coding_system |
1137 (XLSTREAM (XPROCESS (process)->coding_outstream))); | 1148 (XLSTREAM (XPROCESS (process)->coding_outstream))); |
1138 } | 1149 } |
1143 */ | 1154 */ |
1144 (process, codesys)) | 1155 (process, codesys)) |
1145 { | 1156 { |
1146 codesys = Fget_coding_system (codesys); | 1157 codesys = Fget_coding_system (codesys); |
1147 process = get_process (process); | 1158 process = get_process (process); |
1159 CHECK_LIVE_PROCESS (process); | |
1160 | |
1148 set_decoding_stream_coding_system | 1161 set_decoding_stream_coding_system |
1149 (XLSTREAM (XPROCESS (process)->coding_instream), codesys); | 1162 (XLSTREAM (XPROCESS (process)->coding_instream), codesys); |
1150 return Qnil; | 1163 return Qnil; |
1151 } | 1164 } |
1152 | 1165 |
1156 */ | 1169 */ |
1157 (process, codesys)) | 1170 (process, codesys)) |
1158 { | 1171 { |
1159 codesys = Fget_coding_system (codesys); | 1172 codesys = Fget_coding_system (codesys); |
1160 process = get_process (process); | 1173 process = get_process (process); |
1174 CHECK_LIVE_PROCESS (process); | |
1175 | |
1161 set_encoding_stream_coding_system | 1176 set_encoding_stream_coding_system |
1162 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys); | 1177 (XLSTREAM (XPROCESS (process)->coding_outstream), codesys); |
1163 return Qnil; | 1178 return Qnil; |
1164 } | 1179 } |
1165 | 1180 |
1517 Lisp_Object proc = get_process (process); | 1532 Lisp_Object proc = get_process (process); |
1518 | 1533 |
1519 if (network_connection_p (proc)) | 1534 if (network_connection_p (proc)) |
1520 error ("Network connection %s is not a subprocess", | 1535 error ("Network connection %s is not a subprocess", |
1521 XSTRING_DATA (XPROCESS(proc)->name)); | 1536 XSTRING_DATA (XPROCESS(proc)->name)); |
1522 if (!PROCESS_LIVE_P (proc)) | 1537 CHECK_LIVE_PROCESS (proc); |
1523 error ("Process %s is not active", | |
1524 XSTRING_DATA (XPROCESS(proc)->name)); | |
1525 | 1538 |
1526 MAYBE_PROCMETH (kill_child_process, (proc, signo, current_group, nomsg)); | 1539 MAYBE_PROCMETH (kill_child_process, (proc, signo, current_group, nomsg)); |
1527 } | 1540 } |
1528 | 1541 |
1529 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /* | 1542 DEFUN ("interrupt-process", Finterrupt_process, 0, 2, 0, /* |
1873 p->exit_code = 0; | 1886 p->exit_code = 0; |
1874 p->core_dumped = 0; | 1887 p->core_dumped = 0; |
1875 p->tick++; | 1888 p->tick++; |
1876 process_tick++; | 1889 process_tick++; |
1877 } | 1890 } |
1878 else if (!NILP(p->pipe_instream)) | 1891 else if (PROCESS_LIVE_P (p)) |
1879 { | 1892 { |
1880 Fkill_process (proc, Qnil); | 1893 Fkill_process (proc, Qnil); |
1881 /* Do this now, since remove_process will make sigchld_handler do nothing. */ | 1894 /* Do this now, since remove_process will make sigchld_handler do nothing. */ |
1882 p->status_symbol = Qsignal; | 1895 p->status_symbol = Qsignal; |
1883 p->exit_code = SIGKILL; | 1896 p->exit_code = SIGKILL; |
1905 if (GC_PROCESSP (proc) | 1918 if (GC_PROCESSP (proc) |
1906 && (GC_NILP (buffer) || GC_EQ (XPROCESS (proc)->buffer, buffer))) | 1919 && (GC_NILP (buffer) || GC_EQ (XPROCESS (proc)->buffer, buffer))) |
1907 { | 1920 { |
1908 if (network_connection_p (proc)) | 1921 if (network_connection_p (proc)) |
1909 Fdelete_process (proc); | 1922 Fdelete_process (proc); |
1910 else if (!NILP (XPROCESS (proc)->pipe_instream)) | 1923 else if (PROCESS_LIVE_P (XPROCESS (proc))) |
1911 process_send_signal (proc, SIGHUP, 0, 1); | 1924 process_send_signal (proc, SIGHUP, 0, 1); |
1912 } | 1925 } |
1913 } | 1926 } |
1914 } | 1927 } |
1915 | 1928 |
1964 | 1977 |
1965 void | 1978 void |
1966 syms_of_process (void) | 1979 syms_of_process (void) |
1967 { | 1980 { |
1968 defsymbol (&Qprocessp, "processp"); | 1981 defsymbol (&Qprocessp, "processp"); |
1982 defsymbol (&Qprocess_live_p, "process-live-p"); | |
1969 defsymbol (&Qrun, "run"); | 1983 defsymbol (&Qrun, "run"); |
1970 defsymbol (&Qstop, "stop"); | 1984 defsymbol (&Qstop, "stop"); |
1971 defsymbol (&Qopen, "open"); | 1985 defsymbol (&Qopen, "open"); |
1972 defsymbol (&Qclosed, "closed"); | 1986 defsymbol (&Qclosed, "closed"); |
1973 | 1987 |
1976 #ifdef HAVE_MULTICAST | 1990 #ifdef HAVE_MULTICAST |
1977 defsymbol(&Qmulticast, "multicast"); /* Used for occasional warnings */ | 1991 defsymbol(&Qmulticast, "multicast"); /* Used for occasional warnings */ |
1978 #endif | 1992 #endif |
1979 | 1993 |
1980 DEFSUBR (Fprocessp); | 1994 DEFSUBR (Fprocessp); |
1995 DEFSUBR (Fprocess_live_p); | |
1981 DEFSUBR (Fget_process); | 1996 DEFSUBR (Fget_process); |
1982 DEFSUBR (Fget_buffer_process); | 1997 DEFSUBR (Fget_buffer_process); |
1983 DEFSUBR (Fdelete_process); | 1998 DEFSUBR (Fdelete_process); |
1984 DEFSUBR (Fprocess_status); | 1999 DEFSUBR (Fprocess_status); |
1985 DEFSUBR (Fprocess_exit_status); | 2000 DEFSUBR (Fprocess_exit_status); |