Mercurial > emacs
comparison src/process.c @ 95884:d6a4488883dc
Daniel Engeler <engeler at gmail.com>
These changes add serial port access.
* process.c: Add HAVE_SERIAL.
(Fdelete_process, Fprocess_status, Fset_process_buffer)
(Fset_process_filter, Fset_process_sentinel, Fprocess_contact)
(list_processes_1, select_wrapper, Fstop_process)
(Fcontinue_process, Fprocess_send_eof, kill_buffer_processes)
(status_notify): Modify to handle serial processes.
[HAVE_SERIAL] (Fserial_process_configure)
[HAVE_SERIAL] (make_serial_process_unwind, Fmake_serial_process):
New functions.
* process.h (struct Lisp_Process): Add `type'.
* sysdep.c [HAVE_TERMIOS] (serial_open, serial_configure):
New functions.
* w32.c (_sys_read_ahead, sys_read, sys_write): Modify to handle serial ports.
(serial_open, serial_configure) New functions.
* w32.h: Add FILE_SERIAL.
(struct _child_process): Add ovl_read, ovl_write.
| author | Glenn Morris <rgm@gnu.org> |
|---|---|
| date | Fri, 13 Jun 2008 08:08:20 +0000 |
| parents | be7d86474ead |
| children | 99342636fa96 |
comparison
equal
deleted
inserted
replaced
| 95883:37aeb92752e7 | 95884:d6a4488883dc |
|---|---|
| 134 | 134 |
| 135 Lisp_Object Qprocessp; | 135 Lisp_Object Qprocessp; |
| 136 Lisp_Object Qrun, Qstop, Qsignal; | 136 Lisp_Object Qrun, Qstop, Qsignal; |
| 137 Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; | 137 Lisp_Object Qopen, Qclosed, Qconnect, Qfailed, Qlisten; |
| 138 Lisp_Object Qlocal, Qipv4, Qdatagram; | 138 Lisp_Object Qlocal, Qipv4, Qdatagram; |
| 139 Lisp_Object Qreal, Qnetwork, Qserial; | |
| 139 #ifdef AF_INET6 | 140 #ifdef AF_INET6 |
| 140 Lisp_Object Qipv6; | 141 Lisp_Object Qipv6; |
| 141 #endif | 142 #endif |
| 143 Lisp_Object QCport, QCspeed, QCprocess; | |
| 144 Lisp_Object QCbytesize, QCstopbits, QCparity, Qodd, Qeven; | |
| 145 Lisp_Object QCflowcontrol, Qhw, Qsw, QCsummary; | |
| 142 Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype; | 146 Lisp_Object QCname, QCbuffer, QChost, QCservice, QCtype; |
| 143 Lisp_Object QClocal, QCremote, QCcoding; | 147 Lisp_Object QClocal, QCremote, QCcoding; |
| 144 Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; | 148 Lisp_Object QCserver, QCnowait, QCnoquery, QCstop; |
| 145 Lisp_Object QCsentinel, QClog, QCoptions, QCplist; | 149 Lisp_Object QCsentinel, QClog, QCoptions, QCplist; |
| 146 Lisp_Object Qlast_nonmenu_event; | 150 Lisp_Object Qlast_nonmenu_event; |
| 153 /* QCfamily is defined in xfaces.c. */ | 157 /* QCfamily is defined in xfaces.c. */ |
| 154 extern Lisp_Object QCfamily; | 158 extern Lisp_Object QCfamily; |
| 155 /* QCfilter is defined in keyboard.c. */ | 159 /* QCfilter is defined in keyboard.c. */ |
| 156 extern Lisp_Object QCfilter; | 160 extern Lisp_Object QCfilter; |
| 157 | 161 |
| 158 /* a process object is a network connection when its childp field is neither | |
| 159 Qt nor Qnil but is instead a property list (KEY VAL ...). */ | |
| 160 | |
| 161 #ifdef HAVE_SOCKETS | 162 #ifdef HAVE_SOCKETS |
| 162 #define NETCONN_P(p) (CONSP (XPROCESS (p)->childp)) | 163 #define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork)) |
| 163 #define NETCONN1_P(p) (CONSP ((p)->childp)) | 164 #define NETCONN1_P(p) (EQ ((p)->type, Qnetwork)) |
| 165 #define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) | |
| 166 #define SERIALCONN1_P(p) (EQ ((p)->type, Qserial)) | |
| 164 #else | 167 #else |
| 165 #define NETCONN_P(p) 0 | 168 #define NETCONN_P(p) 0 |
| 166 #define NETCONN1_P(p) 0 | 169 #define NETCONN1_P(p) 0 |
| 170 #define SERIALCONN_P(p) 0 | |
| 171 #define SERIALCONN1_P(p) 0 | |
| 167 #endif /* HAVE_SOCKETS */ | 172 #endif /* HAVE_SOCKETS */ |
| 168 | 173 |
| 169 /* Define first descriptor number available for subprocesses. */ | 174 /* Define first descriptor number available for subprocesses. */ |
| 170 #ifdef VMS | 175 #ifdef VMS |
| 171 #define FIRST_PROC_DESC 1 | 176 #define FIRST_PROC_DESC 1 |
| 183 #include "syssignal.h" | 188 #include "syssignal.h" |
| 184 | 189 |
| 185 #include "syswait.h" | 190 #include "syswait.h" |
| 186 | 191 |
| 187 extern char *get_operating_system_release (); | 192 extern char *get_operating_system_release (); |
| 193 | |
| 194 /* Serial processes require termios or Windows. */ | |
| 195 #if defined (HAVE_TERMIOS) || defined (WINDOWSNT) | |
| 196 #define HAVE_SERIAL | |
| 197 #endif | |
| 198 | |
| 199 #ifdef HAVE_SERIAL | |
| 200 /* From sysdep.c or w32.c */ | |
| 201 extern int serial_open (char *port); | |
| 202 extern void serial_configure (struct Lisp_Process *p, Lisp_Object contact); | |
| 203 #endif | |
| 188 | 204 |
| 189 #ifndef USE_CRT_DLL | 205 #ifndef USE_CRT_DLL |
| 190 extern int errno; | 206 extern int errno; |
| 191 #endif | 207 #endif |
| 192 #ifdef VMS | 208 #ifdef VMS |
| 782 | 798 |
| 783 process = get_process (process); | 799 process = get_process (process); |
| 784 p = XPROCESS (process); | 800 p = XPROCESS (process); |
| 785 | 801 |
| 786 p->raw_status_new = 0; | 802 p->raw_status_new = 0; |
| 787 if (NETCONN1_P (p)) | 803 if (NETCONN1_P (p) || SERIALCONN1_P (p)) |
| 788 { | 804 { |
| 789 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); | 805 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); |
| 790 p->tick = ++process_tick; | 806 p->tick = ++process_tick; |
| 791 status_notify (p); | 807 status_notify (p); |
| 792 } | 808 } |
| 859 if (p->raw_status_new) | 875 if (p->raw_status_new) |
| 860 update_status (p); | 876 update_status (p); |
| 861 status = p->status; | 877 status = p->status; |
| 862 if (CONSP (status)) | 878 if (CONSP (status)) |
| 863 status = XCAR (status); | 879 status = XCAR (status); |
| 864 if (NETCONN1_P (p)) | 880 if (NETCONN1_P (p) || SERIALCONN1_P (p)) |
| 865 { | 881 { |
| 866 if (EQ (status, Qexit)) | 882 if (EQ (status, Qexit)) |
| 867 status = Qclosed; | 883 status = Qclosed; |
| 868 else if (EQ (p->command, Qt)) | 884 else if (EQ (p->command, Qt)) |
| 869 status = Qstop; | 885 status = Qstop; |
| 917 | 933 |
| 918 DEFUN ("process-command", Fprocess_command, Sprocess_command, 1, 1, 0, | 934 DEFUN ("process-command", Fprocess_command, Sprocess_command, 1, 1, 0, |
| 919 doc: /* Return the command that was executed to start PROCESS. | 935 doc: /* Return the command that was executed to start PROCESS. |
| 920 This is a list of strings, the first string being the program executed | 936 This is a list of strings, the first string being the program executed |
| 921 and the rest of the strings being the arguments given to it. | 937 and the rest of the strings being the arguments given to it. |
| 922 For a non-child channel, this is nil. */) | 938 For a network or serial process, this is nil (process is running) or t |
| 939 \(process is stopped). */) | |
| 923 (process) | 940 (process) |
| 924 register Lisp_Object process; | 941 register Lisp_Object process; |
| 925 { | 942 { |
| 926 CHECK_PROCESS (process); | 943 CHECK_PROCESS (process); |
| 927 return XPROCESS (process)->command; | 944 return XPROCESS (process)->command; |
| 949 CHECK_PROCESS (process); | 966 CHECK_PROCESS (process); |
| 950 if (!NILP (buffer)) | 967 if (!NILP (buffer)) |
| 951 CHECK_BUFFER (buffer); | 968 CHECK_BUFFER (buffer); |
| 952 p = XPROCESS (process); | 969 p = XPROCESS (process); |
| 953 p->buffer = buffer; | 970 p->buffer = buffer; |
| 954 if (NETCONN1_P (p)) | 971 if (NETCONN1_P (p) || SERIALCONN1_P (p)) |
| 955 p->childp = Fplist_put (p->childp, QCbuffer, buffer); | 972 p->childp = Fplist_put (p->childp, QCbuffer, buffer); |
| 956 setup_process_coding_systems (process); | 973 setup_process_coding_systems (process); |
| 957 return buffer; | 974 return buffer; |
| 958 } | 975 } |
| 959 | 976 |
| 1016 { | 1033 { |
| 1017 FD_CLR (p->infd, &input_wait_mask); | 1034 FD_CLR (p->infd, &input_wait_mask); |
| 1018 FD_CLR (p->infd, &non_keyboard_wait_mask); | 1035 FD_CLR (p->infd, &non_keyboard_wait_mask); |
| 1019 } | 1036 } |
| 1020 else if (EQ (p->filter, Qt) | 1037 else if (EQ (p->filter, Qt) |
| 1021 && !EQ (p->command, Qt)) /* Network process not stopped. */ | 1038 /* Network or serial process not stopped: */ |
| 1039 && !EQ (p->command, Qt)) | |
| 1022 { | 1040 { |
| 1023 FD_SET (p->infd, &input_wait_mask); | 1041 FD_SET (p->infd, &input_wait_mask); |
| 1024 FD_SET (p->infd, &non_keyboard_wait_mask); | 1042 FD_SET (p->infd, &non_keyboard_wait_mask); |
| 1025 } | 1043 } |
| 1026 } | 1044 } |
| 1027 | 1045 |
| 1028 p->filter = filter; | 1046 p->filter = filter; |
| 1029 if (NETCONN1_P (p)) | 1047 if (NETCONN1_P (p) || SERIALCONN1_P (p)) |
| 1030 p->childp = Fplist_put (p->childp, QCfilter, filter); | 1048 p->childp = Fplist_put (p->childp, QCfilter, filter); |
| 1031 setup_process_coding_systems (process); | 1049 setup_process_coding_systems (process); |
| 1032 return filter; | 1050 return filter; |
| 1033 } | 1051 } |
| 1034 | 1052 |
| 1055 | 1073 |
| 1056 CHECK_PROCESS (process); | 1074 CHECK_PROCESS (process); |
| 1057 p = XPROCESS (process); | 1075 p = XPROCESS (process); |
| 1058 | 1076 |
| 1059 p->sentinel = sentinel; | 1077 p->sentinel = sentinel; |
| 1060 if (NETCONN1_P (p)) | 1078 if (NETCONN1_P (p) || SERIALCONN1_P (p)) |
| 1061 p->childp = Fplist_put (p->childp, QCsentinel, sentinel); | 1079 p->childp = Fplist_put (p->childp, QCsentinel, sentinel); |
| 1062 return sentinel; | 1080 return sentinel; |
| 1063 } | 1081 } |
| 1064 | 1082 |
| 1065 DEFUN ("process-sentinel", Fprocess_sentinel, Sprocess_sentinel, | 1083 DEFUN ("process-sentinel", Fprocess_sentinel, Sprocess_sentinel, |
| 1160 #endif | 1178 #endif |
| 1161 | 1179 |
| 1162 DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, | 1180 DEFUN ("process-contact", Fprocess_contact, Sprocess_contact, |
| 1163 1, 2, 0, | 1181 1, 2, 0, |
| 1164 doc: /* Return the contact info of PROCESS; t for a real child. | 1182 doc: /* Return the contact info of PROCESS; t for a real child. |
| 1165 For a net connection, the value depends on the optional KEY arg. | 1183 For a network or serial connection, the value depends on the optional |
| 1166 If KEY is nil, value is a cons cell of the form (HOST SERVICE), | 1184 KEY arg. If KEY is nil, value is a cons cell of the form (HOST |
| 1167 if KEY is t, the complete contact information for the connection is | 1185 SERVICE) for a network connection or (PORT SPEED) for a serial |
| 1168 returned, else the specific value for the keyword KEY is returned. | 1186 connection. If KEY is t, the complete contact information for the |
| 1169 See `make-network-process' for a list of keywords. */) | 1187 connection is returned, else the specific value for the keyword KEY is |
| 1188 returned. See `make-network-process' or `make-serial-process' for a | |
| 1189 list of keywords. */) | |
| 1170 (process, key) | 1190 (process, key) |
| 1171 register Lisp_Object process, key; | 1191 register Lisp_Object process, key; |
| 1172 { | 1192 { |
| 1173 Lisp_Object contact; | 1193 Lisp_Object contact; |
| 1174 | 1194 |
| 1180 && (EQ (key, Qt) || EQ (key, QCremote))) | 1200 && (EQ (key, Qt) || EQ (key, QCremote))) |
| 1181 contact = Fplist_put (contact, QCremote, | 1201 contact = Fplist_put (contact, QCremote, |
| 1182 Fprocess_datagram_address (process)); | 1202 Fprocess_datagram_address (process)); |
| 1183 #endif | 1203 #endif |
| 1184 | 1204 |
| 1185 if (!NETCONN_P (process) || EQ (key, Qt)) | 1205 if ((!NETCONN_P (process) && !SERIALCONN_P (process)) || EQ (key, Qt)) |
| 1186 return contact; | 1206 return contact; |
| 1187 if (NILP (key)) | 1207 if (NILP (key) && NETCONN_P (process)) |
| 1188 return Fcons (Fplist_get (contact, QChost), | 1208 return Fcons (Fplist_get (contact, QChost), |
| 1189 Fcons (Fplist_get (contact, QCservice), Qnil)); | 1209 Fcons (Fplist_get (contact, QCservice), Qnil)); |
| 1210 if (NILP (key) && SERIALCONN_P (process)) | |
| 1211 return Fcons (Fplist_get (contact, QCport), | |
| 1212 Fcons (Fplist_get (contact, QCspeed), Qnil)); | |
| 1190 return Fplist_get (contact, key); | 1213 return Fplist_get (contact, key); |
| 1191 } | 1214 } |
| 1192 | 1215 |
| 1193 DEFUN ("process-plist", Fprocess_plist, Sprocess_plist, | 1216 DEFUN ("process-plist", Fprocess_plist, Sprocess_plist, |
| 1194 1, 1, 0, | 1217 1, 1, 0, |
| 1223 Lisp_Object process; | 1246 Lisp_Object process; |
| 1224 { | 1247 { |
| 1225 return XPROCESS (process)->type; | 1248 return XPROCESS (process)->type; |
| 1226 } | 1249 } |
| 1227 #endif | 1250 #endif |
| 1251 | |
| 1252 DEFUN ("process-type", Fprocess_type, Sprocess_type, 1, 1, 0, | |
| 1253 doc: /* Return the connection type of PROCESS. | |
| 1254 The value is either the symbol `real', `network', or `serial'. | |
| 1255 PROCESS may be a process, a buffer, the name of a process or buffer, or | |
| 1256 nil, indicating the current buffer's process. */) | |
| 1257 (process) | |
| 1258 Lisp_Object process; | |
| 1259 { | |
| 1260 Lisp_Object proc; | |
| 1261 proc = get_process (process); | |
| 1262 return XPROCESS (proc)->type; | |
| 1263 } | |
| 1228 | 1264 |
| 1229 #ifdef HAVE_SOCKETS | 1265 #ifdef HAVE_SOCKETS |
| 1230 DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address, | 1266 DEFUN ("format-network-address", Fformat_network_address, Sformat_network_address, |
| 1231 1, 2, 0, | 1267 1, 2, 0, |
| 1232 doc: /* Convert network ADDRESS from internal format to a string. | 1268 doc: /* Convert network ADDRESS from internal format to a string. |
| 1323 { | 1359 { |
| 1324 int i; | 1360 int i; |
| 1325 | 1361 |
| 1326 proc = Fcdr (XCAR (tail)); | 1362 proc = Fcdr (XCAR (tail)); |
| 1327 p = XPROCESS (proc); | 1363 p = XPROCESS (proc); |
| 1328 if (NILP (p->childp)) | 1364 if (NILP (p->type)) |
| 1329 continue; | 1365 continue; |
| 1330 if (!NILP (query_only) && p->kill_without_query) | 1366 if (!NILP (query_only) && p->kill_without_query) |
| 1331 continue; | 1367 continue; |
| 1332 if (STRINGP (p->name) | 1368 if (STRINGP (p->name) |
| 1333 && ( i = SCHARS (p->name), (i > w_proc))) | 1369 && ( i = SCHARS (p->name), (i > w_proc))) |
| 1391 { | 1427 { |
| 1392 Lisp_Object symbol; | 1428 Lisp_Object symbol; |
| 1393 | 1429 |
| 1394 proc = Fcdr (XCAR (tail)); | 1430 proc = Fcdr (XCAR (tail)); |
| 1395 p = XPROCESS (proc); | 1431 p = XPROCESS (proc); |
| 1396 if (NILP (p->childp)) | 1432 if (NILP (p->type)) |
| 1397 continue; | 1433 continue; |
| 1398 if (!NILP (query_only) && p->kill_without_query) | 1434 if (!NILP (query_only) && p->kill_without_query) |
| 1399 continue; | 1435 continue; |
| 1400 | 1436 |
| 1401 Finsert (1, &p->name); | 1437 Finsert (1, &p->name); |
| 1416 write_string (sys_errlist [XINT (tem)], -1); | 1452 write_string (sys_errlist [XINT (tem)], -1); |
| 1417 else | 1453 else |
| 1418 #endif | 1454 #endif |
| 1419 Fprinc (symbol, Qnil); | 1455 Fprinc (symbol, Qnil); |
| 1420 } | 1456 } |
| 1421 else if (NETCONN1_P (p)) | 1457 else if (NETCONN1_P (p) || SERIALCONN1_P (p)) |
| 1422 { | 1458 { |
| 1423 if (EQ (symbol, Qexit)) | 1459 if (EQ (symbol, Qexit)) |
| 1424 write_string ("closed", -1); | 1460 write_string ("closed", -1); |
| 1425 else if (EQ (p->command, Qt)) | 1461 else if (EQ (p->command, Qt)) |
| 1426 write_string ("stopped", -1); | 1462 write_string ("stopped", -1); |
| 1427 else if (EQ (symbol, Qrun)) | 1463 else if (EQ (symbol, Qrun)) |
| 1428 write_string ("open", -1); | 1464 write_string ("open", -1); |
| 1429 else | 1465 else |
| 1430 Fprinc (symbol, Qnil); | 1466 Fprinc (symbol, Qnil); |
| 1467 } | |
| 1468 else if (SERIALCONN1_P (p)) | |
| 1469 { | |
| 1470 write_string ("running", -1); | |
| 1431 } | 1471 } |
| 1432 else | 1472 else |
| 1433 Fprinc (symbol, Qnil); | 1473 Fprinc (symbol, Qnil); |
| 1434 | 1474 |
| 1435 if (EQ (symbol, Qexit)) | 1475 if (EQ (symbol, Qexit)) |
| 1491 sprintf (tembuf, "(network %s connection to %s)\n", | 1531 sprintf (tembuf, "(network %s connection to %s)\n", |
| 1492 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), | 1532 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), |
| 1493 (STRINGP (host) ? (char *)SDATA (host) : "?")); | 1533 (STRINGP (host) ? (char *)SDATA (host) : "?")); |
| 1494 insert_string (tembuf); | 1534 insert_string (tembuf); |
| 1495 } | 1535 } |
| 1536 else if (SERIALCONN1_P (p)) | |
| 1537 { | |
| 1538 Lisp_Object port = Fplist_get (p->childp, QCport); | |
| 1539 Lisp_Object speed = Fplist_get (p->childp, QCspeed); | |
| 1540 insert_string ("(serial port "); | |
| 1541 if (STRINGP (port)) | |
| 1542 insert_string (SDATA (port)); | |
| 1543 else | |
| 1544 insert_string ("?"); | |
| 1545 if (INTEGERP (speed)) | |
| 1546 { | |
| 1547 sprintf (tembuf, " at %d b/s", XINT (speed)); | |
| 1548 insert_string (tembuf); | |
| 1549 } | |
| 1550 insert_string (")\n"); | |
| 1551 } | |
| 1496 else | 1552 else |
| 1497 { | 1553 { |
| 1498 tem = p->command; | 1554 tem = p->command; |
| 1499 while (1) | 1555 while (1) |
| 1500 { | 1556 { |
| 1617 itself; it's all taken care of here. */ | 1673 itself; it's all taken care of here. */ |
| 1618 record_unwind_protect (start_process_unwind, proc); | 1674 record_unwind_protect (start_process_unwind, proc); |
| 1619 | 1675 |
| 1620 XPROCESS (proc)->childp = Qt; | 1676 XPROCESS (proc)->childp = Qt; |
| 1621 XPROCESS (proc)->plist = Qnil; | 1677 XPROCESS (proc)->plist = Qnil; |
| 1678 XPROCESS (proc)->type = Qreal; | |
| 1622 XPROCESS (proc)->buffer = buffer; | 1679 XPROCESS (proc)->buffer = buffer; |
| 1623 XPROCESS (proc)->sentinel = Qnil; | 1680 XPROCESS (proc)->sentinel = Qnil; |
| 1624 XPROCESS (proc)->filter = Qnil; | 1681 XPROCESS (proc)->filter = Qnil; |
| 1625 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); | 1682 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); |
| 1626 | 1683 |
| 2654 request_sigio (); | 2711 request_sigio (); |
| 2655 return Qnil; | 2712 return Qnil; |
| 2656 } | 2713 } |
| 2657 #endif | 2714 #endif |
| 2658 | 2715 |
| 2716 #ifdef HAVE_SERIAL | |
| 2717 DEFUN ("serial-process-configure", | |
| 2718 Fserial_process_configure, | |
| 2719 Sserial_process_configure, | |
| 2720 0, MANY, 0, | |
| 2721 doc: /* Configure speed, bytesize, etc. of a serial process. | |
| 2722 | |
| 2723 Arguments are specified as keyword/argument pairs. Attributes that | |
| 2724 are not given are re-initialized from the process's current | |
| 2725 configuration (available via the function `process-contact') or set to | |
| 2726 reasonable default values. The following arguments are defined: | |
| 2727 | |
| 2728 :process PROCESS | |
| 2729 :name NAME | |
| 2730 :buffer BUFFER | |
| 2731 :port PORT | |
| 2732 -- Any of these arguments can be given to identify the process that is | |
| 2733 to be configured. If none of these arguments is given, the current | |
| 2734 buffer's process is used. | |
| 2735 | |
| 2736 :speed SPEED -- SPEED is the speed of the serial port in bits per | |
| 2737 second, also called baud rate. Any value can be given for SPEED, but | |
| 2738 most serial ports work only at a few defined values between 1200 and | |
| 2739 115200, with 9600 being the most common value. If SPEED is nil, the | |
| 2740 serial port is not configured any further, i.e., all other arguments | |
| 2741 are ignored. This may be useful for special serial ports such as | |
| 2742 Bluetooth-to-serial converters which can only be configured through AT | |
| 2743 commands. A value of nil for SPEED can be used only when passed | |
| 2744 through `make-serial-process' or `serial-term'. | |
| 2745 | |
| 2746 :bytesize BYTESIZE -- BYTESIZE is the number of bits per byte, which | |
| 2747 can be 7 or 8. If BYTESIZE is not given or nil, a value of 8 is used. | |
| 2748 | |
| 2749 :parity PARITY -- PARITY can be nil (don't use parity), the symbol | |
| 2750 `odd' (use odd parity), or the symbol `even' (use even parity). If | |
| 2751 PARITY is not given, no parity is used. | |
| 2752 | |
| 2753 :stopbits STOPBITS -- STOPBITS is the number of stopbits used to | |
| 2754 terminate a byte transmission. STOPBITS can be 1 or 2. If STOPBITS | |
| 2755 is not given or nil, 1 stopbit is used. | |
| 2756 | |
| 2757 :flowcontrol FLOWCONTROL -- FLOWCONTROL determines the type of | |
| 2758 flowcontrol to be used, which is either nil (don't use flowcontrol), | |
| 2759 the symbol `hw' (use RTS/CTS hardware flowcontrol), or the symbol `sw' | |
| 2760 \(use XON/XOFF software flowcontrol). If FLOWCONTROL is not given, no | |
| 2761 flowcontrol is used. | |
| 2762 | |
| 2763 `serial-process-configure' is called by `make-serial-process' for the | |
| 2764 initial configuration of the serial port. | |
| 2765 | |
| 2766 Examples: | |
| 2767 | |
| 2768 \(serial-process-configure :process "/dev/ttyS0" :speed 1200) | |
| 2769 | |
| 2770 \(serial-process-configure | |
| 2771 :buffer "COM1" :stopbits 1 :parity 'odd :flowcontrol 'hw) | |
| 2772 | |
| 2773 \(serial-process-configure :port "\\\\.\\COM13" :bytesize 7) | |
| 2774 | |
| 2775 usage: (serial-process-configure &rest ARGS) */) | |
| 2776 (nargs, args) | |
| 2777 int nargs; | |
| 2778 Lisp_Object *args; | |
| 2779 { | |
| 2780 struct Lisp_Process *p; | |
| 2781 Lisp_Object contact = Qnil; | |
| 2782 Lisp_Object proc = Qnil; | |
| 2783 struct gcpro gcpro1; | |
| 2784 | |
| 2785 contact = Flist (nargs, args); | |
| 2786 GCPRO1 (contact); | |
| 2787 | |
| 2788 proc = Fplist_get (contact, QCprocess); | |
| 2789 if (NILP (proc)) | |
| 2790 proc = Fplist_get (contact, QCname); | |
| 2791 if (NILP (proc)) | |
| 2792 proc = Fplist_get (contact, QCbuffer); | |
| 2793 if (NILP (proc)) | |
| 2794 proc = Fplist_get (contact, QCport); | |
| 2795 proc = get_process (proc); | |
| 2796 p = XPROCESS (proc); | |
| 2797 if (p->type != Qserial) | |
| 2798 error ("Not a serial process"); | |
| 2799 | |
| 2800 if (NILP (Fplist_get (p->childp, QCspeed))) | |
| 2801 { | |
| 2802 UNGCPRO; | |
| 2803 return Qnil; | |
| 2804 } | |
| 2805 | |
| 2806 serial_configure (p, contact); | |
| 2807 | |
| 2808 UNGCPRO; | |
| 2809 return Qnil; | |
| 2810 } | |
| 2811 #endif /* HAVE_SERIAL */ | |
| 2812 | |
| 2813 #ifdef HAVE_SERIAL | |
| 2814 /* Used by make-serial-process to recover from errors. */ | |
| 2815 Lisp_Object make_serial_process_unwind (Lisp_Object proc) | |
| 2816 { | |
| 2817 if (!PROCESSP (proc)) | |
| 2818 abort (); | |
| 2819 remove_process (proc); | |
| 2820 return Qnil; | |
| 2821 } | |
| 2822 #endif /* HAVE_SERIAL */ | |
| 2823 | |
| 2824 #ifdef HAVE_SERIAL | |
| 2825 DEFUN ("make-serial-process", Fmake_serial_process, Smake_serial_process, | |
| 2826 0, MANY, 0, | |
| 2827 doc: /* Create and return a serial port process. | |
| 2828 | |
| 2829 In Emacs, serial port connections are represented by process objects, | |
| 2830 so input and output work as for subprocesses, and `delete-process' | |
| 2831 closes a serial port connection. However, a serial process has no | |
| 2832 process id, it cannot be signaled, and the status codes are different | |
| 2833 from normal processes. | |
| 2834 | |
| 2835 `make-serial-process' creates a process and a buffer, on which you | |
| 2836 probably want to use `process-send-string'. Try \\[serial-term] for | |
| 2837 an interactive terminal. See below for examples. | |
| 2838 | |
| 2839 Arguments are specified as keyword/argument pairs. The following | |
| 2840 arguments are defined: | |
| 2841 | |
| 2842 :port PORT -- (mandatory) PORT is the path or name of the serial port. | |
| 2843 For example, this could be "/dev/ttyS0" on Unix. On Windows, this | |
| 2844 could be "COM1", or "\\\\.\\COM10" for ports higher than COM9 (double | |
| 2845 the backslashes in strings). | |
| 2846 | |
| 2847 :speed SPEED -- (mandatory) is handled by `serial-process-configure', | |
| 2848 which is called by `make-serial-process'. | |
| 2849 | |
| 2850 :name NAME -- NAME is the name of the process. If NAME is not given, | |
| 2851 the value of PORT is used. | |
| 2852 | |
| 2853 :buffer BUFFER -- BUFFER is the buffer (or buffer-name) to associate | |
| 2854 with the process. Process output goes at the end of that buffer, | |
| 2855 unless you specify an output stream or filter function to handle the | |
| 2856 output. If BUFFER is not given, the value of NAME is used. | |
| 2857 | |
| 2858 :coding CODING -- If CODING is a symbol, it specifies the coding | |
| 2859 system used for both reading and writing for this process. If CODING | |
| 2860 is a cons (DECODING . ENCODING), DECODING is used for reading, and | |
| 2861 ENCODING is used for writing. | |
| 2862 | |
| 2863 :noquery BOOL -- When exiting Emacs, query the user if BOOL is nil and | |
| 2864 the process is running. If BOOL is not given, query before exiting. | |
| 2865 | |
| 2866 :stop BOOL -- Start process in the `stopped' state if BOOL is non-nil. | |
| 2867 In the stopped state, a serial process does not accept incoming data, | |
| 2868 but you can send outgoing data. The stopped state is cleared by | |
| 2869 `continue-process' and set by `stop-process'. | |
| 2870 | |
| 2871 :filter FILTER -- Install FILTER as the process filter. | |
| 2872 | |
| 2873 :sentinel SENTINEL -- Install SENTINEL as the process sentinel. | |
| 2874 | |
| 2875 :plist PLIST -- Install PLIST as the initial plist of the process. | |
| 2876 | |
| 2877 :speed | |
| 2878 :bytesize | |
| 2879 :parity | |
| 2880 :stopbits | |
| 2881 :flowcontrol | |
| 2882 -- These arguments are handled by `serial-process-configure', which is | |
| 2883 called by `make-serial-process'. | |
| 2884 | |
| 2885 The original argument list, possibly modified by later configuration, | |
| 2886 is available via the function `process-contact'. | |
| 2887 | |
| 2888 Examples: | |
| 2889 | |
| 2890 \(make-serial-process :port "/dev/ttyS0" :speed 9600) | |
| 2891 | |
| 2892 \(make-serial-process :port "COM1" :speed 115200 :stopbits 2) | |
| 2893 | |
| 2894 \(make-serial-process :port "\\\\.\\COM13" :speed 1200 :bytesize 7 :parity 'odd) | |
| 2895 | |
| 2896 \(make-serial-process :port "/dev/tty.BlueConsole-SPP-1" :speed nil) | |
| 2897 | |
| 2898 usage: (make-serial-process &rest ARGS) */) | |
| 2899 (nargs, args) | |
| 2900 int nargs; | |
| 2901 Lisp_Object *args; | |
| 2902 { | |
| 2903 int fd = -1; | |
| 2904 Lisp_Object proc, contact, port; | |
| 2905 struct Lisp_Process *p; | |
| 2906 struct gcpro gcpro1; | |
| 2907 Lisp_Object name, buffer; | |
| 2908 Lisp_Object tem, val; | |
| 2909 int specpdl_count = -1; | |
| 2910 | |
| 2911 if (nargs == 0) | |
| 2912 return Qnil; | |
| 2913 | |
| 2914 contact = Flist (nargs, args); | |
| 2915 GCPRO1 (contact); | |
| 2916 | |
| 2917 port = Fplist_get (contact, QCport); | |
| 2918 if (NILP (port)) | |
| 2919 error ("No port specified"); | |
| 2920 CHECK_STRING (port); | |
| 2921 | |
| 2922 if (NILP (Fplist_member (contact, QCspeed))) | |
| 2923 error (":speed not specified"); | |
| 2924 if (!NILP (Fplist_get (contact, QCspeed))) | |
| 2925 CHECK_NUMBER (Fplist_get (contact, QCspeed)); | |
| 2926 | |
| 2927 name = Fplist_get (contact, QCname); | |
| 2928 if (NILP (name)) | |
| 2929 name = port; | |
| 2930 CHECK_STRING (name); | |
| 2931 proc = make_process (name); | |
| 2932 specpdl_count = SPECPDL_INDEX (); | |
| 2933 record_unwind_protect (make_serial_process_unwind, proc); | |
| 2934 p = XPROCESS (proc); | |
| 2935 | |
| 2936 fd = serial_open ((char*) SDATA (port)); | |
| 2937 p->infd = fd; | |
| 2938 p->outfd = fd; | |
| 2939 if (fd > max_process_desc) | |
| 2940 max_process_desc = fd; | |
| 2941 chan_process[fd] = proc; | |
| 2942 | |
| 2943 buffer = Fplist_get (contact, QCbuffer); | |
| 2944 if (NILP (buffer)) | |
| 2945 buffer = name; | |
| 2946 buffer = Fget_buffer_create (buffer); | |
| 2947 p->buffer = buffer; | |
| 2948 | |
| 2949 p->childp = contact; | |
| 2950 p->plist = Fcopy_sequence (Fplist_get (contact, QCplist)); | |
| 2951 p->type = Qserial; | |
| 2952 p->sentinel = Fplist_get (contact, QCsentinel); | |
| 2953 p->filter = Fplist_get (contact, QCfilter); | |
| 2954 p->log = Qnil; | |
| 2955 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) | |
| 2956 p->kill_without_query = 1; | |
| 2957 if (tem = Fplist_get (contact, QCstop), !NILP (tem)) | |
| 2958 p->command = Qt; | |
| 2959 p->pty_flag = 0; | |
| 2960 | |
| 2961 if (!EQ (p->command, Qt)) | |
| 2962 { | |
| 2963 FD_SET (fd, &input_wait_mask); | |
| 2964 FD_SET (fd, &non_keyboard_wait_mask); | |
| 2965 } | |
| 2966 | |
| 2967 if (BUFFERP (buffer)) | |
| 2968 { | |
| 2969 set_marker_both (p->mark, buffer, | |
| 2970 BUF_ZV (XBUFFER (buffer)), | |
| 2971 BUF_ZV_BYTE (XBUFFER (buffer))); | |
| 2972 } | |
| 2973 | |
| 2974 tem = Fplist_member (contact, QCcoding); | |
| 2975 if (!NILP (tem) && (!CONSP (tem) || !CONSP (XCDR (tem)))) | |
| 2976 tem = Qnil; | |
| 2977 | |
| 2978 val = Qnil; | |
| 2979 if (!NILP (tem)) | |
| 2980 { | |
| 2981 val = XCAR (XCDR (tem)); | |
| 2982 if (CONSP (val)) | |
| 2983 val = XCAR (val); | |
| 2984 } | |
| 2985 else if (!NILP (Vcoding_system_for_read)) | |
| 2986 val = Vcoding_system_for_read; | |
| 2987 else if ((!NILP (buffer) && NILP (XBUFFER (buffer)->enable_multibyte_characters)) | |
| 2988 || (NILP (buffer) && NILP (buffer_defaults.enable_multibyte_characters))) | |
| 2989 val = Qnil; | |
| 2990 p->decode_coding_system = val; | |
| 2991 | |
| 2992 val = Qnil; | |
| 2993 if (!NILP (tem)) | |
| 2994 { | |
| 2995 val = XCAR (XCDR (tem)); | |
| 2996 if (CONSP (val)) | |
| 2997 val = XCDR (val); | |
| 2998 } | |
| 2999 else if (!NILP (Vcoding_system_for_write)) | |
| 3000 val = Vcoding_system_for_write; | |
| 3001 else if ((!NILP (buffer) && NILP (XBUFFER (buffer)->enable_multibyte_characters)) | |
| 3002 || (NILP (buffer) && NILP (buffer_defaults.enable_multibyte_characters))) | |
| 3003 val = Qnil; | |
| 3004 p->encode_coding_system = val; | |
| 3005 | |
| 3006 setup_process_coding_systems (proc); | |
| 3007 p->decoding_buf = make_uninit_string (0); | |
| 3008 p->decoding_carryover = 0; | |
| 3009 p->encoding_buf = make_uninit_string (0); | |
| 3010 p->inherit_coding_system_flag | |
| 3011 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); | |
| 3012 | |
| 3013 Fserial_process_configure(nargs, args); | |
| 3014 | |
| 3015 specpdl_ptr = specpdl + specpdl_count; | |
| 3016 | |
| 3017 UNGCPRO; | |
| 3018 return proc; | |
| 3019 } | |
| 3020 #endif /* HAVE_SERIAL */ | |
| 3021 | |
| 2659 /* Create a network stream/datagram client/server process. Treated | 3022 /* Create a network stream/datagram client/server process. Treated |
| 2660 exactly like a normal process when reading and writing. Primary | 3023 exactly like a normal process when reading and writing. Primary |
| 2661 differences are in status display and process deletion. A network | 3024 differences are in status display and process deletion. A network |
| 2662 connection has no PID; you cannot signal it. All you can do is | 3025 connection has no PID; you cannot signal it. All you can do is |
| 2663 stop/continue it and deactivate/close it via delete-process */ | 3026 stop/continue it and deactivate/close it via delete-process */ |
| 3393 | 3756 |
| 3394 p = XPROCESS (proc); | 3757 p = XPROCESS (proc); |
| 3395 | 3758 |
| 3396 p->childp = contact; | 3759 p->childp = contact; |
| 3397 p->plist = Fcopy_sequence (Fplist_get (contact, QCplist)); | 3760 p->plist = Fcopy_sequence (Fplist_get (contact, QCplist)); |
| 3761 p->type = Qnetwork; | |
| 3398 | 3762 |
| 3399 p->buffer = buffer; | 3763 p->buffer = buffer; |
| 3400 p->sentinel = sentinel; | 3764 p->sentinel = sentinel; |
| 3401 p->filter = filter; | 3765 p->filter = filter; |
| 3402 p->log = Fplist_get (contact, QClog); | 3766 p->log = Fplist_get (contact, QClog); |
| 4111 conv_sockaddr_to_lisp (&saddr.sa, len)); | 4475 conv_sockaddr_to_lisp (&saddr.sa, len)); |
| 4112 #endif | 4476 #endif |
| 4113 | 4477 |
| 4114 p->childp = contact; | 4478 p->childp = contact; |
| 4115 p->plist = Fcopy_sequence (ps->plist); | 4479 p->plist = Fcopy_sequence (ps->plist); |
| 4480 p->type = Qnetwork; | |
| 4116 | 4481 |
| 4117 p->buffer = buffer; | 4482 p->buffer = buffer; |
| 4118 p->sentinel = ps->sentinel; | 4483 p->sentinel = ps->sentinel; |
| 4119 p->filter = ps->filter; | 4484 p->filter = ps->filter; |
| 4120 p->command = Qnil; | 4485 p->command = Qnil; |
| 4809 ; | 5174 ; |
| 4810 /* Note that we cannot distinguish between no input | 5175 /* Note that we cannot distinguish between no input |
| 4811 available now and a closed pipe. | 5176 available now and a closed pipe. |
| 4812 With luck, a closed pipe will be accompanied by | 5177 With luck, a closed pipe will be accompanied by |
| 4813 subprocess termination and SIGCHLD. */ | 5178 subprocess termination and SIGCHLD. */ |
| 4814 else if (nread == 0 && !NETCONN_P (proc)) | 5179 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) |
| 4815 ; | 5180 ; |
| 4816 #endif /* O_NDELAY */ | 5181 #endif /* O_NDELAY */ |
| 4817 #endif /* O_NONBLOCK */ | 5182 #endif /* O_NONBLOCK */ |
| 4818 #ifdef HAVE_PTYS | 5183 #ifdef HAVE_PTYS |
| 4819 /* On some OSs with ptys, when the process on one end of | 5184 /* On some OSs with ptys, when the process on one end of |
| 4837 } | 5202 } |
| 4838 #endif /* HAVE_PTYS */ | 5203 #endif /* HAVE_PTYS */ |
| 4839 /* If we can detect process termination, don't consider the process | 5204 /* If we can detect process termination, don't consider the process |
| 4840 gone just because its pipe is closed. */ | 5205 gone just because its pipe is closed. */ |
| 4841 #ifdef SIGCHLD | 5206 #ifdef SIGCHLD |
| 4842 else if (nread == 0 && !NETCONN_P (proc)) | 5207 else if (nread == 0 && !NETCONN_P (proc) && !SERIALCONN_P (proc)) |
| 4843 ; | 5208 ; |
| 4844 #endif | 5209 #endif |
| 4845 else | 5210 else |
| 4846 { | 5211 { |
| 4847 /* Preserve status of processes already terminated. */ | 5212 /* Preserve status of processes already terminated. */ |
| 5626 buf += rv; | 5991 buf += rv; |
| 5627 len -= rv; | 5992 len -= rv; |
| 5628 this -= rv; | 5993 this -= rv; |
| 5629 } | 5994 } |
| 5630 | 5995 |
| 5631 /* If we sent just part of the string, put in an EOF | 5996 /* If we sent just part of the string, put in an EOF (C-d) |
| 5632 to force it through, before we send the rest. */ | 5997 to force it through, before we send the rest. */ |
| 5633 if (len > 0) | 5998 if (len > 0) |
| 5634 Fprocess_send_eof (proc); | 5999 Fprocess_send_eof (proc); |
| 5635 } | 6000 } |
| 5636 } | 6001 } |
| 5746 struct Lisp_Process *p; | 6111 struct Lisp_Process *p; |
| 5747 | 6112 |
| 5748 proc = get_process (process); | 6113 proc = get_process (process); |
| 5749 p = XPROCESS (proc); | 6114 p = XPROCESS (proc); |
| 5750 | 6115 |
| 5751 if (!EQ (p->childp, Qt)) | 6116 if (!EQ (p->type, Qreal)) |
| 5752 error ("Process %s is not a subprocess", | 6117 error ("Process %s is not a subprocess", |
| 5753 SDATA (p->name)); | 6118 SDATA (p->name)); |
| 5754 if (p->infd < 0) | 6119 if (p->infd < 0) |
| 5755 error ("Process %s is not active", | 6120 error ("Process %s is not active", |
| 5756 SDATA (p->name)); | 6121 SDATA (p->name)); |
| 5789 int no_pgrp = 0; | 6154 int no_pgrp = 0; |
| 5790 | 6155 |
| 5791 proc = get_process (process); | 6156 proc = get_process (process); |
| 5792 p = XPROCESS (proc); | 6157 p = XPROCESS (proc); |
| 5793 | 6158 |
| 5794 if (!EQ (p->childp, Qt)) | 6159 if (!EQ (p->type, Qreal)) |
| 5795 error ("Process %s is not a subprocess", | 6160 error ("Process %s is not a subprocess", |
| 5796 SDATA (p->name)); | 6161 SDATA (p->name)); |
| 5797 if (p->infd < 0) | 6162 if (p->infd < 0) |
| 5798 error ("Process %s is not active", | 6163 error ("Process %s is not active", |
| 5799 SDATA (p->name)); | 6164 SDATA (p->name)); |
| 6038 } | 6403 } |
| 6039 | 6404 |
| 6040 DEFUN ("stop-process", Fstop_process, Sstop_process, 0, 2, 0, | 6405 DEFUN ("stop-process", Fstop_process, Sstop_process, 0, 2, 0, |
| 6041 doc: /* Stop process PROCESS. May be process or name of one. | 6406 doc: /* Stop process PROCESS. May be process or name of one. |
| 6042 See function `interrupt-process' for more details on usage. | 6407 See function `interrupt-process' for more details on usage. |
| 6043 If PROCESS is a network process, inhibit handling of incoming traffic. */) | 6408 If PROCESS is a network or serial process, inhibit handling of incoming |
| 6409 traffic. */) | |
| 6044 (process, current_group) | 6410 (process, current_group) |
| 6045 Lisp_Object process, current_group; | 6411 Lisp_Object process, current_group; |
| 6046 { | 6412 { |
| 6047 #ifdef HAVE_SOCKETS | 6413 #ifdef HAVE_SOCKETS |
| 6048 if (PROCESSP (process) && NETCONN_P (process)) | 6414 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) |
| 6049 { | 6415 { |
| 6050 struct Lisp_Process *p; | 6416 struct Lisp_Process *p; |
| 6051 | 6417 |
| 6052 p = XPROCESS (process); | 6418 p = XPROCESS (process); |
| 6053 if (NILP (p->command) | 6419 if (NILP (p->command) |
| 6069 } | 6435 } |
| 6070 | 6436 |
| 6071 DEFUN ("continue-process", Fcontinue_process, Scontinue_process, 0, 2, 0, | 6437 DEFUN ("continue-process", Fcontinue_process, Scontinue_process, 0, 2, 0, |
| 6072 doc: /* Continue process PROCESS. May be process or name of one. | 6438 doc: /* Continue process PROCESS. May be process or name of one. |
| 6073 See function `interrupt-process' for more details on usage. | 6439 See function `interrupt-process' for more details on usage. |
| 6074 If PROCESS is a network process, resume handling of incoming traffic. */) | 6440 If PROCESS is a network or serial process, resume handling of incoming |
| 6441 traffic. */) | |
| 6075 (process, current_group) | 6442 (process, current_group) |
| 6076 Lisp_Object process, current_group; | 6443 Lisp_Object process, current_group; |
| 6077 { | 6444 { |
| 6078 #ifdef HAVE_SOCKETS | 6445 #ifdef HAVE_SOCKETS |
| 6079 if (PROCESSP (process) && NETCONN_P (process)) | 6446 if (PROCESSP (process) && (NETCONN_P (process) || SERIALCONN_P (process))) |
| 6080 { | 6447 { |
| 6081 struct Lisp_Process *p; | 6448 struct Lisp_Process *p; |
| 6082 | 6449 |
| 6083 p = XPROCESS (process); | 6450 p = XPROCESS (process); |
| 6084 if (EQ (p->command, Qt) | 6451 if (EQ (p->command, Qt) |
| 6085 && p->infd >= 0 | 6452 && p->infd >= 0 |
| 6086 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) | 6453 && (!EQ (p->filter, Qt) || EQ (p->status, Qlisten))) |
| 6087 { | 6454 { |
| 6088 FD_SET (p->infd, &input_wait_mask); | 6455 FD_SET (p->infd, &input_wait_mask); |
| 6089 FD_SET (p->infd, &non_keyboard_wait_mask); | 6456 FD_SET (p->infd, &non_keyboard_wait_mask); |
| 6457 #ifdef WINDOWSNT | |
| 6458 if (fd_info[ p->infd ].flags & FILE_SERIAL) | |
| 6459 PurgeComm (fd_info[ p->infd ].hnd, PURGE_RXABORT | PURGE_RXCLEAR); | |
| 6460 #endif | |
| 6461 #ifdef HAVE_TERMIOS | |
| 6462 tcflush (p->infd, TCIFLUSH); | |
| 6463 #endif | |
| 6090 } | 6464 } |
| 6091 p->command = Qnil; | 6465 p->command = Qnil; |
| 6092 return process; | 6466 return process; |
| 6093 } | 6467 } |
| 6094 #endif | 6468 #endif |
| 6270 EOF comes after any text already sent to it. | 6644 EOF comes after any text already sent to it. |
| 6271 PROCESS may be a process, a buffer, the name of a process or buffer, or | 6645 PROCESS may be a process, a buffer, the name of a process or buffer, or |
| 6272 nil, indicating the current buffer's process. | 6646 nil, indicating the current buffer's process. |
| 6273 If PROCESS is a network connection, or is a process communicating | 6647 If PROCESS is a network connection, or is a process communicating |
| 6274 through a pipe (as opposed to a pty), then you cannot send any more | 6648 through a pipe (as opposed to a pty), then you cannot send any more |
| 6275 text to PROCESS after you call this function. */) | 6649 text to PROCESS after you call this function. |
| 6650 If PROCESS is a serial process, wait until all output written to the | |
| 6651 process has been transmitted to the serial port. */) | |
| 6276 (process) | 6652 (process) |
| 6277 Lisp_Object process; | 6653 Lisp_Object process; |
| 6278 { | 6654 { |
| 6279 Lisp_Object proc; | 6655 Lisp_Object proc; |
| 6280 struct coding_system *coding; | 6656 struct coding_system *coding; |
| 6300 #ifdef VMS | 6676 #ifdef VMS |
| 6301 send_process (proc, "\032", 1, Qnil); /* ^z */ | 6677 send_process (proc, "\032", 1, Qnil); /* ^z */ |
| 6302 #else | 6678 #else |
| 6303 if (XPROCESS (proc)->pty_flag) | 6679 if (XPROCESS (proc)->pty_flag) |
| 6304 send_process (proc, "\004", 1, Qnil); | 6680 send_process (proc, "\004", 1, Qnil); |
| 6681 else if (XPROCESS (proc)->type == Qserial) | |
| 6682 { | |
| 6683 #ifdef HAVE_TERMIOS | |
| 6684 if (tcdrain (XPROCESS (proc)->outfd) != 0) | |
| 6685 error ("tcdrain() failed: %s", emacs_strerror (errno)); | |
| 6686 #endif | |
| 6687 /* Do nothing on Windows because writes are blocking. */ | |
| 6688 } | |
| 6305 else | 6689 else |
| 6306 { | 6690 { |
| 6307 int old_outfd, new_outfd; | 6691 int old_outfd, new_outfd; |
| 6308 | 6692 |
| 6309 #ifdef HAVE_SHUTDOWN | 6693 #ifdef HAVE_SHUTDOWN |
| 6310 /* If this is a network connection, or socketpair is used | 6694 /* If this is a network connection, or socketpair is used |
| 6311 for communication with the subprocess, call shutdown to cause EOF. | 6695 for communication with the subprocess, call shutdown to cause EOF. |
| 6312 (In some old system, shutdown to socketpair doesn't work. | 6696 (In some old system, shutdown to socketpair doesn't work. |
| 6313 Then we just can't win.) */ | 6697 Then we just can't win.) */ |
| 6314 if (XPROCESS (proc)->pid == 0 | 6698 if (XPROCESS (proc)->type == Qnetwork |
| 6315 || XPROCESS (proc)->outfd == XPROCESS (proc)->infd) | 6699 || XPROCESS (proc)->outfd == XPROCESS (proc)->infd) |
| 6316 shutdown (XPROCESS (proc)->outfd, 1); | 6700 shutdown (XPROCESS (proc)->outfd, 1); |
| 6317 /* In case of socketpair, outfd == infd, so don't close it. */ | 6701 /* In case of socketpair, outfd == infd, so don't close it. */ |
| 6318 if (XPROCESS (proc)->outfd != XPROCESS (proc)->infd) | 6702 if (XPROCESS (proc)->outfd != XPROCESS (proc)->infd) |
| 6319 emacs_close (XPROCESS (proc)->outfd); | 6703 emacs_close (XPROCESS (proc)->outfd); |
| 6353 { | 6737 { |
| 6354 proc = XCDR (XCAR (tail)); | 6738 proc = XCDR (XCAR (tail)); |
| 6355 if (PROCESSP (proc) | 6739 if (PROCESSP (proc) |
| 6356 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) | 6740 && (NILP (buffer) || EQ (XPROCESS (proc)->buffer, buffer))) |
| 6357 { | 6741 { |
| 6358 if (NETCONN_P (proc)) | 6742 if (NETCONN_P (proc) || SERIALCONN_P (proc)) |
| 6359 Fdelete_process (proc); | 6743 Fdelete_process (proc); |
| 6360 else if (XPROCESS (proc)->infd >= 0) | 6744 else if (XPROCESS (proc)->infd >= 0) |
| 6361 process_send_signal (proc, SIGHUP, Qnil, 1); | 6745 process_send_signal (proc, SIGHUP, Qnil, 1); |
| 6362 } | 6746 } |
| 6363 } | 6747 } |
| 6462 p = 0; | 6846 p = 0; |
| 6463 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) | 6847 for (tail = Vprocess_alist; CONSP (tail); tail = XCDR (tail)) |
| 6464 { | 6848 { |
| 6465 proc = XCDR (XCAR (tail)); | 6849 proc = XCDR (XCAR (tail)); |
| 6466 p = XPROCESS (proc); | 6850 p = XPROCESS (proc); |
| 6467 if (EQ (p->childp, Qt) && p->pid == pid) | 6851 if (EQ (p->type, Qreal) && p->pid == pid) |
| 6468 break; | 6852 break; |
| 6469 p = 0; | 6853 p = 0; |
| 6470 } | 6854 } |
| 6471 | 6855 |
| 6472 /* Look for an asynchronous process whose pid hasn't been filled | 6856 /* Look for an asynchronous process whose pid hasn't been filled |
| 6684 | 7068 |
| 6685 /* If process is still active, read any output that remains. */ | 7069 /* If process is still active, read any output that remains. */ |
| 6686 while (! EQ (p->filter, Qt) | 7070 while (! EQ (p->filter, Qt) |
| 6687 && ! EQ (p->status, Qconnect) | 7071 && ! EQ (p->status, Qconnect) |
| 6688 && ! EQ (p->status, Qlisten) | 7072 && ! EQ (p->status, Qlisten) |
| 6689 && ! EQ (p->command, Qt) /* Network process not stopped. */ | 7073 /* Network or serial process not stopped: */ |
| 7074 && ! EQ (p->command, Qt) | |
| 6690 && p->infd >= 0 | 7075 && p->infd >= 0 |
| 6691 && p != deleting_process | 7076 && p != deleting_process |
| 6692 && read_process_output (proc, p->infd) > 0); | 7077 && read_process_output (proc, p->infd) > 0); |
| 6693 | 7078 |
| 6694 buffer = p->buffer; | 7079 buffer = p->buffer; |
| 7070 Qipv6 = intern ("ipv6"); | 7455 Qipv6 = intern ("ipv6"); |
| 7071 staticpro (&Qipv6); | 7456 staticpro (&Qipv6); |
| 7072 #endif | 7457 #endif |
| 7073 Qdatagram = intern ("datagram"); | 7458 Qdatagram = intern ("datagram"); |
| 7074 staticpro (&Qdatagram); | 7459 staticpro (&Qdatagram); |
| 7460 | |
| 7461 QCport = intern (":port"); | |
| 7462 staticpro (&QCport); | |
| 7463 QCspeed = intern (":speed"); | |
| 7464 staticpro (&QCspeed); | |
| 7465 QCprocess = intern (":process"); | |
| 7466 staticpro (&QCprocess); | |
| 7467 | |
| 7468 QCbytesize = intern (":bytesize"); | |
| 7469 staticpro (&QCbytesize); | |
| 7470 QCstopbits = intern (":stopbits"); | |
| 7471 staticpro (&QCstopbits); | |
| 7472 QCparity = intern (":parity"); | |
| 7473 staticpro (&QCparity); | |
| 7474 Qodd = intern ("odd"); | |
| 7475 staticpro (&Qodd); | |
| 7476 Qeven = intern ("even"); | |
| 7477 staticpro (&Qeven); | |
| 7478 QCflowcontrol = intern (":flowcontrol"); | |
| 7479 staticpro (&QCflowcontrol); | |
| 7480 Qhw = intern ("hw"); | |
| 7481 staticpro (&Qhw); | |
| 7482 Qsw = intern ("sw"); | |
| 7483 staticpro (&Qsw); | |
| 7484 QCsummary = intern (":summary"); | |
| 7485 staticpro (&QCsummary); | |
| 7486 | |
| 7487 Qreal = intern ("real"); | |
| 7488 staticpro (&Qreal); | |
| 7489 Qnetwork = intern ("network"); | |
| 7490 staticpro (&Qnetwork); | |
| 7491 Qserial = intern ("serial"); | |
| 7492 staticpro (&Qserial); | |
| 7075 | 7493 |
| 7076 QCname = intern (":name"); | 7494 QCname = intern (":name"); |
| 7077 staticpro (&QCname); | 7495 staticpro (&QCname); |
| 7078 QCbuffer = intern (":buffer"); | 7496 QCbuffer = intern (":buffer"); |
| 7079 staticpro (&QCbuffer); | 7497 staticpro (&QCbuffer); |
| 7168 defsubr (&Sprocess_plist); | 7586 defsubr (&Sprocess_plist); |
| 7169 defsubr (&Sset_process_plist); | 7587 defsubr (&Sset_process_plist); |
| 7170 defsubr (&Slist_processes); | 7588 defsubr (&Slist_processes); |
| 7171 defsubr (&Sprocess_list); | 7589 defsubr (&Sprocess_list); |
| 7172 defsubr (&Sstart_process); | 7590 defsubr (&Sstart_process); |
| 7591 #ifdef HAVE_SERIAL | |
| 7592 defsubr (&Sserial_process_configure); | |
| 7593 defsubr (&Smake_serial_process); | |
| 7594 #endif /* HAVE_SERIAL */ | |
| 7173 #ifdef HAVE_SOCKETS | 7595 #ifdef HAVE_SOCKETS |
| 7174 defsubr (&Sset_network_process_option); | 7596 defsubr (&Sset_network_process_option); |
| 7175 defsubr (&Smake_network_process); | 7597 defsubr (&Smake_network_process); |
| 7176 defsubr (&Sformat_network_address); | 7598 defsubr (&Sformat_network_address); |
| 7177 #endif /* HAVE_SOCKETS */ | 7599 #endif /* HAVE_SOCKETS */ |
| 7197 defsubr (&Scontinue_process); | 7619 defsubr (&Scontinue_process); |
| 7198 defsubr (&Sprocess_running_child_p); | 7620 defsubr (&Sprocess_running_child_p); |
| 7199 defsubr (&Sprocess_send_eof); | 7621 defsubr (&Sprocess_send_eof); |
| 7200 defsubr (&Ssignal_process); | 7622 defsubr (&Ssignal_process); |
| 7201 defsubr (&Swaiting_for_user_input_p); | 7623 defsubr (&Swaiting_for_user_input_p); |
| 7202 /* defsubr (&Sprocess_connection); */ | 7624 defsubr (&Sprocess_type); |
| 7203 defsubr (&Sset_process_coding_system); | 7625 defsubr (&Sset_process_coding_system); |
| 7204 defsubr (&Sprocess_coding_system); | 7626 defsubr (&Sprocess_coding_system); |
| 7205 defsubr (&Sset_process_filter_multibyte); | 7627 defsubr (&Sset_process_filter_multibyte); |
| 7206 defsubr (&Sprocess_filter_multibyte_p); | 7628 defsubr (&Sprocess_filter_multibyte_p); |
| 7207 } | 7629 } |
