aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c233
1 files changed, 119 insertions, 114 deletions
diff --git a/src/process.c b/src/process.c
index ceb5c81d32b..a43655e4da8 100644
--- a/src/process.c
+++ b/src/process.c
@@ -173,9 +173,9 @@ extern Lisp_Object QCfamily;
173extern Lisp_Object QCfilter; 173extern Lisp_Object QCfilter;
174 174
175#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork)) 175#define NETCONN_P(p) (EQ (XPROCESS (p)->type, Qnetwork))
176#define NETCONN1_P(p) (EQ ((p)->type, Qnetwork)) 176#define NETCONN1_P(p) (EQ (p->type, Qnetwork))
177#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial)) 177#define SERIALCONN_P(p) (EQ (XPROCESS (p)->type, Qserial))
178#define SERIALCONN1_P(p) (EQ ((p)->type, Qserial)) 178#define SERIALCONN1_P(p) (EQ (p->type, Qserial))
179 179
180#ifndef HAVE_H_ERRNO 180#ifndef HAVE_H_ERRNO
181extern int h_errno; 181extern int h_errno;
@@ -428,7 +428,7 @@ static void
428update_status (struct Lisp_Process *p) 428update_status (struct Lisp_Process *p)
429{ 429{
430 eassert (p->raw_status_new); 430 eassert (p->raw_status_new);
431 p->status = status_convert (p->raw_status); 431 PSET (p, status, status_convert (p->raw_status));
432 p->raw_status_new = 0; 432 p->raw_status_new = 0;
433} 433}
434 434
@@ -441,7 +441,7 @@ status_convert (int w)
441 if (WIFSTOPPED (w)) 441 if (WIFSTOPPED (w))
442 return Fcons (Qstop, Fcons (make_number (WSTOPSIG (w)), Qnil)); 442 return Fcons (Qstop, Fcons (make_number (WSTOPSIG (w)), Qnil));
443 else if (WIFEXITED (w)) 443 else if (WIFEXITED (w))
444 return Fcons (Qexit, Fcons (make_number (WRETCODE (w)), 444 return Fcons (Qexit, Fcons (make_number (WEXITSTATUS (w)),
445 WCOREDUMP (w) ? Qt : Qnil)); 445 WCOREDUMP (w) ? Qt : Qnil));
446 else if (WIFSIGNALED (w)) 446 else if (WIFSIGNALED (w))
447 return Fcons (Qsignal, Fcons (make_number (WTERMSIG (w)), 447 return Fcons (Qsignal, Fcons (make_number (WTERMSIG (w)),
@@ -497,7 +497,7 @@ status_message (struct Lisp_Process *p)
497 { 497 {
498 int c1, c2; 498 int c1, c2;
499 499
500 string = make_unibyte_string (signame, strlen (signame)); 500 string = build_unibyte_string (signame);
501 if (! NILP (Vlocale_coding_system)) 501 if (! NILP (Vlocale_coding_system))
502 string = (code_convert_string_norecord 502 string = (code_convert_string_norecord
503 (string, Vlocale_coding_system, 0)); 503 (string, Vlocale_coding_system, 0));
@@ -626,8 +626,8 @@ make_process (Lisp_Object name)
626 p = allocate_process (); 626 p = allocate_process ();
627 /* Initialize Lisp data. Note that allocate_process initializes all 627 /* Initialize Lisp data. Note that allocate_process initializes all
628 Lisp data to nil, so do it only for slots which should not be nil. */ 628 Lisp data to nil, so do it only for slots which should not be nil. */
629 p->status = Qrun; 629 PSET (p, status, Qrun);
630 p->mark = Fmake_marker (); 630 PSET (p, mark, Fmake_marker ());
631 631
632 /* Initialize non-Lisp data. Note that allocate_process zeroes out all 632 /* Initialize non-Lisp data. Note that allocate_process zeroes out all
633 non-Lisp data, so do it only for slots which should not be zero. */ 633 non-Lisp data, so do it only for slots which should not be zero. */
@@ -648,7 +648,7 @@ make_process (Lisp_Object name)
648 name1 = concat2 (name, make_formatted_string (suffix, "<%"pMd">", i)); 648 name1 = concat2 (name, make_formatted_string (suffix, "<%"pMd">", i));
649 } 649 }
650 name = name1; 650 name = name1;
651 p->name = name; 651 PSET (p, name, name);
652 XSETPROCESS (val, p); 652 XSETPROCESS (val, p);
653 Vprocess_alist = Fcons (Fcons (name, val), Vprocess_alist); 653 Vprocess_alist = Fcons (Fcons (name, val), Vprocess_alist);
654 return val; 654 return val;
@@ -745,7 +745,7 @@ nil, indicating the current buffer's process. */)
745 p->raw_status_new = 0; 745 p->raw_status_new = 0;
746 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 746 if (NETCONN1_P (p) || SERIALCONN1_P (p))
747 { 747 {
748 p->status = Fcons (Qexit, Fcons (make_number (0), Qnil)); 748 PSET (p, status, Fcons (Qexit, Fcons (make_number (0), Qnil)));
749 p->tick = ++process_tick; 749 p->tick = ++process_tick;
750 status_notify (p); 750 status_notify (p);
751 redisplay_preserve_echo_area (13); 751 redisplay_preserve_echo_area (13);
@@ -774,8 +774,7 @@ nil, indicating the current buffer's process. */)
774 { 774 {
775 Fkill_process (process, Qnil); 775 Fkill_process (process, Qnil);
776 /* Do this now, since remove_process will make sigchld_handler do nothing. */ 776 /* Do this now, since remove_process will make sigchld_handler do nothing. */
777 p->status 777 PSET (p, status, Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil)));
778 = Fcons (Qsignal, Fcons (make_number (SIGKILL), Qnil));
779 p->tick = ++process_tick; 778 p->tick = ++process_tick;
780 status_notify (p); 779 status_notify (p);
781 redisplay_preserve_echo_area (13); 780 redisplay_preserve_echo_area (13);
@@ -902,9 +901,9 @@ Return BUFFER. */)
902 if (!NILP (buffer)) 901 if (!NILP (buffer))
903 CHECK_BUFFER (buffer); 902 CHECK_BUFFER (buffer);
904 p = XPROCESS (process); 903 p = XPROCESS (process);
905 p->buffer = buffer; 904 PSET (p, buffer, buffer);
906 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 905 if (NETCONN1_P (p) || SERIALCONN1_P (p))
907 p->childp = Fplist_put (p->childp, QCbuffer, buffer); 906 PSET (p, childp, Fplist_put (p->childp, QCbuffer, buffer));
908 setup_process_coding_systems (process); 907 setup_process_coding_systems (process);
909 return buffer; 908 return buffer;
910} 909}
@@ -975,9 +974,9 @@ The string argument is normally a multibyte string, except:
975 } 974 }
976 } 975 }
977 976
978 p->filter = filter; 977 PSET (p, filter, filter);
979 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 978 if (NETCONN1_P (p) || SERIALCONN1_P (p))
980 p->childp = Fplist_put (p->childp, QCfilter, filter); 979 PSET (p, childp, Fplist_put (p->childp, QCfilter, filter));
981 setup_process_coding_systems (process); 980 setup_process_coding_systems (process);
982 return filter; 981 return filter;
983} 982}
@@ -1004,9 +1003,9 @@ It gets two arguments: the process, and a string describing the change. */)
1004 CHECK_PROCESS (process); 1003 CHECK_PROCESS (process);
1005 p = XPROCESS (process); 1004 p = XPROCESS (process);
1006 1005
1007 p->sentinel = sentinel; 1006 PSET (p, sentinel, sentinel);
1008 if (NETCONN1_P (p) || SERIALCONN1_P (p)) 1007 if (NETCONN1_P (p) || SERIALCONN1_P (p))
1009 p->childp = Fplist_put (p->childp, QCsentinel, sentinel); 1008 PSET (p, childp, Fplist_put (p->childp, QCsentinel, sentinel));
1010 return sentinel; 1009 return sentinel;
1011} 1010}
1012 1011
@@ -1139,7 +1138,7 @@ DEFUN ("set-process-plist", Fset_process_plist, Sset_process_plist,
1139 CHECK_PROCESS (process); 1138 CHECK_PROCESS (process);
1140 CHECK_LIST (plist); 1139 CHECK_LIST (plist);
1141 1140
1142 XPROCESS (process)->plist = plist; 1141 PSET (XPROCESS (process), plist, plist);
1143 return plist; 1142 return plist;
1144} 1143}
1145 1144
@@ -1325,18 +1324,18 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1325 itself; it's all taken care of here. */ 1324 itself; it's all taken care of here. */
1326 record_unwind_protect (start_process_unwind, proc); 1325 record_unwind_protect (start_process_unwind, proc);
1327 1326
1328 XPROCESS (proc)->childp = Qt; 1327 PSET (XPROCESS (proc), childp, Qt);
1329 XPROCESS (proc)->plist = Qnil; 1328 PSET (XPROCESS (proc), plist, Qnil);
1330 XPROCESS (proc)->type = Qreal; 1329 PSET (XPROCESS (proc), type, Qreal);
1331 XPROCESS (proc)->buffer = buffer; 1330 PSET (XPROCESS (proc), buffer, buffer);
1332 XPROCESS (proc)->sentinel = Qnil; 1331 PSET (XPROCESS (proc), sentinel, Qnil);
1333 XPROCESS (proc)->filter = Qnil; 1332 PSET (XPROCESS (proc), filter, Qnil);
1334 XPROCESS (proc)->command = Flist (nargs - 2, args + 2); 1333 PSET (XPROCESS (proc), command, Flist (nargs - 2, args + 2));
1335 1334
1336#ifdef HAVE_GNUTLS 1335#ifdef HAVE_GNUTLS
1337 /* AKA GNUTLS_INITSTAGE(proc). */ 1336 /* AKA GNUTLS_INITSTAGE(proc). */
1338 XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY; 1337 XPROCESS (proc)->gnutls_initstage = GNUTLS_STAGE_EMPTY;
1339 XPROCESS (proc)->gnutls_cred_type = Qnil; 1338 PSET (XPROCESS (proc), gnutls_cred_type, Qnil);
1340#endif 1339#endif
1341 1340
1342#ifdef ADAPTIVE_READ_BUFFERING 1341#ifdef ADAPTIVE_READ_BUFFERING
@@ -1376,7 +1375,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1376 else if (CONSP (Vdefault_process_coding_system)) 1375 else if (CONSP (Vdefault_process_coding_system))
1377 val = XCAR (Vdefault_process_coding_system); 1376 val = XCAR (Vdefault_process_coding_system);
1378 } 1377 }
1379 XPROCESS (proc)->decode_coding_system = val; 1378 PSET (XPROCESS (proc), decode_coding_system, val);
1380 1379
1381 val = Vcoding_system_for_write; 1380 val = Vcoding_system_for_write;
1382 if (NILP (val)) 1381 if (NILP (val))
@@ -1396,7 +1395,7 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1396 else if (CONSP (Vdefault_process_coding_system)) 1395 else if (CONSP (Vdefault_process_coding_system))
1397 val = XCDR (Vdefault_process_coding_system); 1396 val = XCDR (Vdefault_process_coding_system);
1398 } 1397 }
1399 XPROCESS (proc)->encode_coding_system = val; 1398 PSET (XPROCESS (proc), encode_coding_system, val);
1400 /* Note: At this moment, the above coding system may leave 1399 /* Note: At this moment, the above coding system may leave
1401 text-conversion or eol-conversion unspecified. They will be 1400 text-conversion or eol-conversion unspecified. They will be
1402 decided after we read output from the process and decode it by 1401 decided after we read output from the process and decode it by
@@ -1405,9 +1404,9 @@ usage: (start-process NAME BUFFER PROGRAM &rest PROGRAM-ARGS) */)
1405 } 1404 }
1406 1405
1407 1406
1408 XPROCESS (proc)->decoding_buf = empty_unibyte_string; 1407 PSET (XPROCESS (proc), decoding_buf, empty_unibyte_string);
1409 XPROCESS (proc)->decoding_carryover = 0; 1408 XPROCESS (proc)->decoding_carryover = 0;
1410 XPROCESS (proc)->encoding_buf = empty_unibyte_string; 1409 PSET (XPROCESS (proc), encoding_buf, empty_unibyte_string);
1411 1410
1412 XPROCESS (proc)->inherit_coding_system_flag 1411 XPROCESS (proc)->inherit_coding_system_flag
1413 = !(NILP (buffer) || !inherit_process_coding_system); 1412 = !(NILP (buffer) || !inherit_process_coding_system);
@@ -1629,7 +1628,7 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1629 more portable (see USG_SUBTTY_WORKS above). */ 1628 more portable (see USG_SUBTTY_WORKS above). */
1630 1629
1631 XPROCESS (process)->pty_flag = pty_flag; 1630 XPROCESS (process)->pty_flag = pty_flag;
1632 XPROCESS (process)->status = Qrun; 1631 PSET (XPROCESS (process), status, Qrun);
1633 1632
1634 /* Delay interrupts until we have a chance to store 1633 /* Delay interrupts until we have a chance to store
1635 the new fork's pid in its process structure */ 1634 the new fork's pid in its process structure */
@@ -1868,10 +1867,10 @@ create_process (Lisp_Object process, char **new_argv, Lisp_Object current_dir)
1868 1867
1869#ifdef HAVE_PTYS 1868#ifdef HAVE_PTYS
1870 if (pty_flag) 1869 if (pty_flag)
1871 XPROCESS (process)->tty_name = build_string (pty_name); 1870 PSET (XPROCESS (process), tty_name, build_string (pty_name));
1872 else 1871 else
1873#endif 1872#endif
1874 XPROCESS (process)->tty_name = Qnil; 1873 PSET (XPROCESS (process), tty_name, Qnil);
1875 1874
1876#if !defined (WINDOWSNT) && defined (FD_CLOEXEC) 1875#if !defined (WINDOWSNT) && defined (FD_CLOEXEC)
1877 /* Wait for child_setup to complete in case that vfork is 1876 /* Wait for child_setup to complete in case that vfork is
@@ -1966,7 +1965,7 @@ create_pty (Lisp_Object process)
1966 more portable (see USG_SUBTTY_WORKS above). */ 1965 more portable (see USG_SUBTTY_WORKS above). */
1967 1966
1968 XPROCESS (process)->pty_flag = pty_flag; 1967 XPROCESS (process)->pty_flag = pty_flag;
1969 XPROCESS (process)->status = Qrun; 1968 PSET (XPROCESS (process), status, Qrun);
1970 setup_process_coding_systems (process); 1969 setup_process_coding_systems (process);
1971 1970
1972 FD_SET (inchannel, &input_wait_mask); 1971 FD_SET (inchannel, &input_wait_mask);
@@ -1977,10 +1976,10 @@ create_pty (Lisp_Object process)
1977 XPROCESS (process)->pid = -2; 1976 XPROCESS (process)->pid = -2;
1978#ifdef HAVE_PTYS 1977#ifdef HAVE_PTYS
1979 if (pty_flag) 1978 if (pty_flag)
1980 XPROCESS (process)->tty_name = build_string (pty_name); 1979 PSET (XPROCESS (process), tty_name, build_string (pty_name));
1981 else 1980 else
1982#endif 1981#endif
1983 XPROCESS (process)->tty_name = Qnil; 1982 PSET (XPROCESS (process), tty_name, Qnil);
1984} 1983}
1985 1984
1986 1985
@@ -2369,7 +2368,7 @@ OPTION is not a supported option, return nil instead; otherwise return t. */)
2369 2368
2370 if (set_socket_option (s, option, value)) 2369 if (set_socket_option (s, option, value))
2371 { 2370 {
2372 p->childp = Fplist_put (p->childp, option, value); 2371 PSET (p, childp, Fplist_put (p->childp, option, value));
2373 return Qt; 2372 return Qt;
2374 } 2373 }
2375 2374
@@ -2602,18 +2601,18 @@ usage: (make-serial-process &rest ARGS) */)
2602 if (NILP (buffer)) 2601 if (NILP (buffer))
2603 buffer = name; 2602 buffer = name;
2604 buffer = Fget_buffer_create (buffer); 2603 buffer = Fget_buffer_create (buffer);
2605 p->buffer = buffer; 2604 PSET (p, buffer, buffer);
2606 2605
2607 p->childp = contact; 2606 PSET (p, childp, contact);
2608 p->plist = Fcopy_sequence (Fplist_get (contact, QCplist)); 2607 PSET (p, plist, Fcopy_sequence (Fplist_get (contact, QCplist)));
2609 p->type = Qserial; 2608 PSET (p, type, Qserial);
2610 p->sentinel = Fplist_get (contact, QCsentinel); 2609 PSET (p, sentinel, Fplist_get (contact, QCsentinel));
2611 p->filter = Fplist_get (contact, QCfilter); 2610 PSET (p, filter, Fplist_get (contact, QCfilter));
2612 p->log = Qnil; 2611 PSET (p, log, Qnil);
2613 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) 2612 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
2614 p->kill_without_query = 1; 2613 p->kill_without_query = 1;
2615 if (tem = Fplist_get (contact, QCstop), !NILP (tem)) 2614 if (tem = Fplist_get (contact, QCstop), !NILP (tem))
2616 p->command = Qt; 2615 PSET (p, command, Qt);
2617 p->pty_flag = 0; 2616 p->pty_flag = 0;
2618 2617
2619 if (!EQ (p->command, Qt)) 2618 if (!EQ (p->command, Qt))
@@ -2645,7 +2644,7 @@ usage: (make-serial-process &rest ARGS) */)
2645 else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters))) 2644 else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
2646 || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))) 2645 || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
2647 val = Qnil; 2646 val = Qnil;
2648 p->decode_coding_system = val; 2647 PSET (p, decode_coding_system, val);
2649 2648
2650 val = Qnil; 2649 val = Qnil;
2651 if (!NILP (tem)) 2650 if (!NILP (tem))
@@ -2659,12 +2658,12 @@ usage: (make-serial-process &rest ARGS) */)
2659 else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters))) 2658 else if ((!NILP (buffer) && NILP (BVAR (XBUFFER (buffer), enable_multibyte_characters)))
2660 || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters)))) 2659 || (NILP (buffer) && NILP (BVAR (&buffer_defaults, enable_multibyte_characters))))
2661 val = Qnil; 2660 val = Qnil;
2662 p->encode_coding_system = val; 2661 PSET (p, encode_coding_system, val);
2663 2662
2664 setup_process_coding_systems (proc); 2663 setup_process_coding_systems (proc);
2665 p->decoding_buf = empty_unibyte_string; 2664 PSET (p, decoding_buf, empty_unibyte_string);
2666 p->decoding_carryover = 0; 2665 p->decoding_carryover = 0;
2667 p->encoding_buf = empty_unibyte_string; 2666 PSET (p, encoding_buf, empty_unibyte_string);
2668 p->inherit_coding_system_flag 2667 p->inherit_coding_system_flag
2669 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); 2668 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system);
2670 2669
@@ -3401,23 +3400,23 @@ usage: (make-network-process &rest ARGS) */)
3401 3400
3402 p = XPROCESS (proc); 3401 p = XPROCESS (proc);
3403 3402
3404 p->childp = contact; 3403 PSET (p, childp, contact);
3405 p->plist = Fcopy_sequence (Fplist_get (contact, QCplist)); 3404 PSET (p, plist, Fcopy_sequence (Fplist_get (contact, QCplist)));
3406 p->type = Qnetwork; 3405 PSET (p, type, Qnetwork);
3407 3406
3408 p->buffer = buffer; 3407 PSET (p, buffer, buffer);
3409 p->sentinel = sentinel; 3408 PSET (p, sentinel, sentinel);
3410 p->filter = filter; 3409 PSET (p, filter, filter);
3411 p->log = Fplist_get (contact, QClog); 3410 PSET (p, log, Fplist_get (contact, QClog));
3412 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem)) 3411 if (tem = Fplist_get (contact, QCnoquery), !NILP (tem))
3413 p->kill_without_query = 1; 3412 p->kill_without_query = 1;
3414 if ((tem = Fplist_get (contact, QCstop), !NILP (tem))) 3413 if ((tem = Fplist_get (contact, QCstop), !NILP (tem)))
3415 p->command = Qt; 3414 PSET (p, command, Qt);
3416 p->pid = 0; 3415 p->pid = 0;
3417 p->infd = inch; 3416 p->infd = inch;
3418 p->outfd = outch; 3417 p->outfd = outch;
3419 if (is_server && socktype != SOCK_DGRAM) 3418 if (is_server && socktype != SOCK_DGRAM)
3420 p->status = Qlisten; 3419 PSET (p, status, Qlisten);
3421 3420
3422 /* Make the process marker point into the process buffer (if any). */ 3421 /* Make the process marker point into the process buffer (if any). */
3423 if (BUFFERP (buffer)) 3422 if (BUFFERP (buffer))
@@ -3431,7 +3430,7 @@ usage: (make-network-process &rest ARGS) */)
3431 /* We may get here if connect did succeed immediately. However, 3430 /* We may get here if connect did succeed immediately. However,
3432 in that case, we still need to signal this like a non-blocking 3431 in that case, we still need to signal this like a non-blocking
3433 connection. */ 3432 connection. */
3434 p->status = Qconnect; 3433 PSET (p, status, Qconnect);
3435 if (!FD_ISSET (inch, &connect_wait_mask)) 3434 if (!FD_ISSET (inch, &connect_wait_mask))
3436 { 3435 {
3437 FD_SET (inch, &connect_wait_mask); 3436 FD_SET (inch, &connect_wait_mask);
@@ -3498,7 +3497,7 @@ usage: (make-network-process &rest ARGS) */)
3498 else 3497 else
3499 val = Qnil; 3498 val = Qnil;
3500 } 3499 }
3501 p->decode_coding_system = val; 3500 PSET (p, decode_coding_system, val);
3502 3501
3503 if (!NILP (tem)) 3502 if (!NILP (tem))
3504 { 3503 {
@@ -3532,13 +3531,13 @@ usage: (make-network-process &rest ARGS) */)
3532 else 3531 else
3533 val = Qnil; 3532 val = Qnil;
3534 } 3533 }
3535 p->encode_coding_system = val; 3534 PSET (p, encode_coding_system, val);
3536 } 3535 }
3537 setup_process_coding_systems (proc); 3536 setup_process_coding_systems (proc);
3538 3537
3539 p->decoding_buf = empty_unibyte_string; 3538 PSET (p, decoding_buf, empty_unibyte_string);
3540 p->decoding_carryover = 0; 3539 p->decoding_carryover = 0;
3541 p->encoding_buf = empty_unibyte_string; 3540 PSET (p, encoding_buf, empty_unibyte_string);
3542 3541
3543 p->inherit_coding_system_flag 3542 p->inherit_coding_system_flag
3544 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system); 3543 = !(!NILP (tem) || NILP (buffer) || !inherit_process_coding_system);
@@ -4151,18 +4150,18 @@ server_accept_connection (Lisp_Object server, int channel)
4151 conv_sockaddr_to_lisp (&saddr.sa, len)); 4150 conv_sockaddr_to_lisp (&saddr.sa, len));
4152#endif 4151#endif
4153 4152
4154 p->childp = contact; 4153 PSET (p, childp, contact);
4155 p->plist = Fcopy_sequence (ps->plist); 4154 PSET (p, plist, Fcopy_sequence (ps->plist));
4156 p->type = Qnetwork; 4155 PSET (p, type, Qnetwork);
4157 4156
4158 p->buffer = buffer; 4157 PSET (p, buffer, buffer);
4159 p->sentinel = ps->sentinel; 4158 PSET (p, sentinel, ps->sentinel);
4160 p->filter = ps->filter; 4159 PSET (p, filter, ps->filter);
4161 p->command = Qnil; 4160 PSET (p, command, Qnil);
4162 p->pid = 0; 4161 p->pid = 0;
4163 p->infd = s; 4162 p->infd = s;
4164 p->outfd = s; 4163 p->outfd = s;
4165 p->status = Qrun; 4164 PSET (p, status, Qrun);
4166 4165
4167 /* Client processes for accepted connections are not stopped initially. */ 4166 /* Client processes for accepted connections are not stopped initially. */
4168 if (!EQ (p->filter, Qt)) 4167 if (!EQ (p->filter, Qt))
@@ -4179,13 +4178,13 @@ server_accept_connection (Lisp_Object server, int channel)
4179 of the new process should reflect the settings at the time the 4178 of the new process should reflect the settings at the time the
4180 server socket was opened; not the current settings. */ 4179 server socket was opened; not the current settings. */
4181 4180
4182 p->decode_coding_system = ps->decode_coding_system; 4181 PSET (p, decode_coding_system, ps->decode_coding_system);
4183 p->encode_coding_system = ps->encode_coding_system; 4182 PSET (p, encode_coding_system, ps->encode_coding_system);
4184 setup_process_coding_systems (proc); 4183 setup_process_coding_systems (proc);
4185 4184
4186 p->decoding_buf = empty_unibyte_string; 4185 PSET (p, decoding_buf, empty_unibyte_string);
4187 p->decoding_carryover = 0; 4186 p->decoding_carryover = 0;
4188 p->encoding_buf = empty_unibyte_string; 4187 PSET (p, encoding_buf, empty_unibyte_string);
4189 4188
4190 p->inherit_coding_system_flag 4189 p->inherit_coding_system_flag
4191 = (NILP (buffer) ? 0 : ps->inherit_coding_system_flag); 4190 = (NILP (buffer) ? 0 : ps->inherit_coding_system_flag);
@@ -4287,7 +4286,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4287 FD_ZERO (&Writeok); 4286 FD_ZERO (&Writeok);
4288 4287
4289 if (time_limit == 0 && nsecs == 0 && wait_proc && !NILP (Vinhibit_quit) 4288 if (time_limit == 0 && nsecs == 0 && wait_proc && !NILP (Vinhibit_quit)
4290 && !(CONSP (wait_proc->status) && EQ (XCAR (wait_proc->status), Qexit))) 4289 && !(CONSP (wait_proc->status)
4290 && EQ (XCAR (wait_proc->status), Qexit)))
4291 message ("Blocking call to accept-process-output with quit inhibited!!"); 4291 message ("Blocking call to accept-process-output with quit inhibited!!");
4292 4292
4293 /* If wait_proc is a process to watch, set wait_channel accordingly. */ 4293 /* If wait_proc is a process to watch, set wait_channel accordingly. */
@@ -4886,10 +4886,10 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4886 if (p->pid == -2) 4886 if (p->pid == -2)
4887 { 4887 {
4888 /* If the EIO occurs on a pty, sigchld_handler's 4888 /* If the EIO occurs on a pty, sigchld_handler's
4889 wait3() will not find the process object to 4889 waitpid() will not find the process object to
4890 delete. Do it here. */ 4890 delete. Do it here. */
4891 p->tick = ++process_tick; 4891 p->tick = ++process_tick;
4892 p->status = Qfailed; 4892 PSET (p, status, Qfailed);
4893 } 4893 }
4894 else 4894 else
4895 kill (getpid (), SIGCHLD); 4895 kill (getpid (), SIGCHLD);
@@ -4909,8 +4909,8 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4909 if (XPROCESS (proc)->raw_status_new) 4909 if (XPROCESS (proc)->raw_status_new)
4910 update_status (XPROCESS (proc)); 4910 update_status (XPROCESS (proc));
4911 if (EQ (XPROCESS (proc)->status, Qrun)) 4911 if (EQ (XPROCESS (proc)->status, Qrun))
4912 XPROCESS (proc)->status 4912 PSET (XPROCESS (proc), status,
4913 = Fcons (Qexit, Fcons (make_number (256), Qnil)); 4913 Fcons (Qexit, Fcons (make_number (256), Qnil)));
4914 } 4914 }
4915 } 4915 }
4916#ifdef NON_BLOCKING_CONNECT 4916#ifdef NON_BLOCKING_CONNECT
@@ -4958,12 +4958,13 @@ wait_reading_process_output (intmax_t time_limit, int nsecs, int read_kbd,
4958 if (xerrno) 4958 if (xerrno)
4959 { 4959 {
4960 p->tick = ++process_tick; 4960 p->tick = ++process_tick;
4961 p->status = Fcons (Qfailed, Fcons (make_number (xerrno), Qnil)); 4961 PSET (p, status,
4962 Fcons (Qfailed, Fcons (make_number (xerrno), Qnil)));
4962 deactivate_process (proc); 4963 deactivate_process (proc);
4963 } 4964 }
4964 else 4965 else
4965 { 4966 {
4966 p->status = Qrun; 4967 PSET (p, status, Qrun);
4967 /* Execute the sentinel here. If we had relied on 4968 /* Execute the sentinel here. If we had relied on
4968 status_notify to do it later, it will read input 4969 status_notify to do it later, it will read input
4969 from the process before calling the sentinel. */ 4970 from the process before calling the sentinel. */
@@ -5163,7 +5164,7 @@ read_process_output (Lisp_Object proc, register int channel)
5163 /* A new coding system might be found. */ 5164 /* A new coding system might be found. */
5164 if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) 5165 if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
5165 { 5166 {
5166 p->decode_coding_system = Vlast_coding_system_used; 5167 PSET (p, decode_coding_system, Vlast_coding_system_used);
5167 5168
5168 /* Don't call setup_coding_system for 5169 /* Don't call setup_coding_system for
5169 proc_decode_coding_system[channel] here. It is done in 5170 proc_decode_coding_system[channel] here. It is done in
@@ -5179,8 +5180,8 @@ read_process_output (Lisp_Object proc, register int channel)
5179 if (NILP (p->encode_coding_system) 5180 if (NILP (p->encode_coding_system)
5180 && proc_encode_coding_system[p->outfd]) 5181 && proc_encode_coding_system[p->outfd])
5181 { 5182 {
5182 p->encode_coding_system 5183 PSET (p, encode_coding_system,
5183 = coding_inherit_eol_type (Vlast_coding_system_used, Qnil); 5184 coding_inherit_eol_type (Vlast_coding_system_used, Qnil));
5184 setup_coding_system (p->encode_coding_system, 5185 setup_coding_system (p->encode_coding_system,
5185 proc_encode_coding_system[p->outfd]); 5186 proc_encode_coding_system[p->outfd]);
5186 } 5187 }
@@ -5189,7 +5190,7 @@ read_process_output (Lisp_Object proc, register int channel)
5189 if (coding->carryover_bytes > 0) 5190 if (coding->carryover_bytes > 0)
5190 { 5191 {
5191 if (SCHARS (p->decoding_buf) < coding->carryover_bytes) 5192 if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
5192 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5193 PSET (p, decoding_buf, make_uninit_string (coding->carryover_bytes));
5193 memcpy (SDATA (p->decoding_buf), coding->carryover, 5194 memcpy (SDATA (p->decoding_buf), coding->carryover,
5194 coding->carryover_bytes); 5195 coding->carryover_bytes);
5195 p->decoding_carryover = coding->carryover_bytes; 5196 p->decoding_carryover = coding->carryover_bytes;
@@ -5245,14 +5246,16 @@ read_process_output (Lisp_Object proc, register int channel)
5245 old_begv_byte = BEGV_BYTE; 5246 old_begv_byte = BEGV_BYTE;
5246 old_zv_byte = ZV_BYTE; 5247 old_zv_byte = ZV_BYTE;
5247 5248
5248 BVAR (current_buffer, read_only) = Qnil; 5249 BSET (current_buffer, read_only, Qnil);
5249 5250
5250 /* Insert new output into buffer 5251 /* Insert new output into buffer
5251 at the current end-of-output marker, 5252 at the current end-of-output marker,
5252 thus preserving logical ordering of input and output. */ 5253 thus preserving logical ordering of input and output. */
5253 if (XMARKER (p->mark)->buffer) 5254 if (XMARKER (p->mark)->buffer)
5254 SET_PT_BOTH (clip_to_bounds (BEGV, marker_position (p->mark), ZV), 5255 SET_PT_BOTH (clip_to_bounds (BEGV,
5255 clip_to_bounds (BEGV_BYTE, marker_byte_position (p->mark), 5256 marker_position (p->mark), ZV),
5257 clip_to_bounds (BEGV_BYTE,
5258 marker_byte_position (p->mark),
5256 ZV_BYTE)); 5259 ZV_BYTE));
5257 else 5260 else
5258 SET_PT_BOTH (ZV, ZV_BYTE); 5261 SET_PT_BOTH (ZV, ZV_BYTE);
@@ -5271,12 +5274,12 @@ read_process_output (Lisp_Object proc, register int channel)
5271 similar code in the previous `if' block. */ 5274 similar code in the previous `if' block. */
5272 if (!EQ (p->decode_coding_system, Vlast_coding_system_used)) 5275 if (!EQ (p->decode_coding_system, Vlast_coding_system_used))
5273 { 5276 {
5274 p->decode_coding_system = Vlast_coding_system_used; 5277 PSET (p, decode_coding_system, Vlast_coding_system_used);
5275 if (NILP (p->encode_coding_system) 5278 if (NILP (p->encode_coding_system)
5276 && proc_encode_coding_system[p->outfd]) 5279 && proc_encode_coding_system[p->outfd])
5277 { 5280 {
5278 p->encode_coding_system 5281 PSET (p, encode_coding_system,
5279 = coding_inherit_eol_type (Vlast_coding_system_used, Qnil); 5282 coding_inherit_eol_type (Vlast_coding_system_used, Qnil));
5280 setup_coding_system (p->encode_coding_system, 5283 setup_coding_system (p->encode_coding_system,
5281 proc_encode_coding_system[p->outfd]); 5284 proc_encode_coding_system[p->outfd]);
5282 } 5285 }
@@ -5284,7 +5287,7 @@ read_process_output (Lisp_Object proc, register int channel)
5284 if (coding->carryover_bytes > 0) 5287 if (coding->carryover_bytes > 0)
5285 { 5288 {
5286 if (SCHARS (p->decoding_buf) < coding->carryover_bytes) 5289 if (SCHARS (p->decoding_buf) < coding->carryover_bytes)
5287 p->decoding_buf = make_uninit_string (coding->carryover_bytes); 5290 PSET (p, decoding_buf, make_uninit_string (coding->carryover_bytes));
5288 memcpy (SDATA (p->decoding_buf), coding->carryover, 5291 memcpy (SDATA (p->decoding_buf), coding->carryover,
5289 coding->carryover_bytes); 5292 coding->carryover_bytes);
5290 p->decoding_carryover = coding->carryover_bytes; 5293 p->decoding_carryover = coding->carryover_bytes;
@@ -5334,7 +5337,7 @@ read_process_output (Lisp_Object proc, register int channel)
5334 Fnarrow_to_region (make_number (old_begv), make_number (old_zv)); 5337 Fnarrow_to_region (make_number (old_begv), make_number (old_zv));
5335 5338
5336 5339
5337 BVAR (current_buffer, read_only) = old_read_only; 5340 BSET (current_buffer, read_only, old_read_only);
5338 SET_PT_BOTH (opoint, opoint_byte); 5341 SET_PT_BOTH (opoint, opoint_byte);
5339 } 5342 }
5340 /* Handling the process output should not deactivate the mark. */ 5343 /* Handling the process output should not deactivate the mark. */
@@ -5401,9 +5404,9 @@ write_queue_push (struct Lisp_Process *p, Lisp_Object input_obj,
5401 entry = Fcons (obj, Fcons (make_number (offset), make_number (len))); 5404 entry = Fcons (obj, Fcons (make_number (offset), make_number (len)));
5402 5405
5403 if (front) 5406 if (front)
5404 p->write_queue = Fcons (entry, p->write_queue); 5407 PSET (p, write_queue, Fcons (entry, p->write_queue));
5405 else 5408 else
5406 p->write_queue = nconc2 (p->write_queue, Fcons (entry, Qnil)); 5409 PSET (p, write_queue, nconc2 (p->write_queue, Fcons (entry, Qnil)));
5407} 5410}
5408 5411
5409/* Remove the first element in the write_queue of process P, put its 5412/* Remove the first element in the write_queue of process P, put its
@@ -5421,7 +5424,7 @@ write_queue_pop (struct Lisp_Process *p, Lisp_Object *obj,
5421 return 0; 5424 return 0;
5422 5425
5423 entry = XCAR (p->write_queue); 5426 entry = XCAR (p->write_queue);
5424 p->write_queue = XCDR (p->write_queue); 5427 PSET (p, write_queue, XCDR (p->write_queue));
5425 5428
5426 *obj = XCAR (entry); 5429 *obj = XCAR (entry);
5427 offset_length = XCDR (entry); 5430 offset_length = XCDR (entry);
@@ -5468,8 +5471,8 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5468 && !NILP (BVAR (XBUFFER (object), enable_multibyte_characters))) 5471 && !NILP (BVAR (XBUFFER (object), enable_multibyte_characters)))
5469 || EQ (object, Qt)) 5472 || EQ (object, Qt))
5470 { 5473 {
5471 p->encode_coding_system 5474 PSET (p, encode_coding_system,
5472 = complement_process_encoding_system (p->encode_coding_system); 5475 complement_process_encoding_system (p->encode_coding_system));
5473 if (!EQ (Vlast_coding_system_used, p->encode_coding_system)) 5476 if (!EQ (Vlast_coding_system_used, p->encode_coding_system))
5474 { 5477 {
5475 /* The coding system for encoding was changed to raw-text 5478 /* The coding system for encoding was changed to raw-text
@@ -5690,7 +5693,7 @@ send_process (volatile Lisp_Object proc, const char *volatile buf,
5690 proc = process_sent_to; 5693 proc = process_sent_to;
5691 p = XPROCESS (proc); 5694 p = XPROCESS (proc);
5692 p->raw_status_new = 0; 5695 p->raw_status_new = 0;
5693 p->status = Fcons (Qexit, Fcons (make_number (256), Qnil)); 5696 PSET (p, status, Fcons (Qexit, Fcons (make_number (256), Qnil)));
5694 p->tick = ++process_tick; 5697 p->tick = ++process_tick;
5695 deactivate_process (proc); 5698 deactivate_process (proc);
5696 error ("SIGPIPE raised on process %s; closed it", SDATA (p->name)); 5699 error ("SIGPIPE raised on process %s; closed it", SDATA (p->name));
@@ -5919,7 +5922,7 @@ process_send_signal (Lisp_Object process, int signo, Lisp_Object current_group,
5919#ifdef SIGCONT 5922#ifdef SIGCONT
5920 case SIGCONT: 5923 case SIGCONT:
5921 p->raw_status_new = 0; 5924 p->raw_status_new = 0;
5922 p->status = Qrun; 5925 PSET (p, status, Qrun);
5923 p->tick = ++process_tick; 5926 p->tick = ++process_tick;
5924 if (!nomsg) 5927 if (!nomsg)
5925 { 5928 {
@@ -6015,7 +6018,7 @@ traffic. */)
6015 FD_CLR (p->infd, &input_wait_mask); 6018 FD_CLR (p->infd, &input_wait_mask);
6016 FD_CLR (p->infd, &non_keyboard_wait_mask); 6019 FD_CLR (p->infd, &non_keyboard_wait_mask);
6017 } 6020 }
6018 p->command = Qt; 6021 PSET (p, command, Qt);
6019 return process; 6022 return process;
6020 } 6023 }
6021#ifndef SIGTSTP 6024#ifndef SIGTSTP
@@ -6051,7 +6054,7 @@ traffic. */)
6051 tcflush (p->infd, TCIFLUSH); 6054 tcflush (p->infd, TCIFLUSH);
6052#endif /* not WINDOWSNT */ 6055#endif /* not WINDOWSNT */
6053 } 6056 }
6054 p->command = Qnil; 6057 PSET (p, command, Qnil);
6055 return process; 6058 return process;
6056 } 6059 }
6057#ifdef SIGCONT 6060#ifdef SIGCONT
@@ -6347,7 +6350,7 @@ sigchld_handler (int signo)
6347 do 6350 do
6348 { 6351 {
6349 errno = 0; 6352 errno = 0;
6350 pid = wait3 (&w, WNOHANG | WUNTRACED, 0); 6353 pid = waitpid (-1, &w, WNOHANG | WUNTRACED);
6351 } 6354 }
6352 while (pid < 0 && errno == EINTR); 6355 while (pid < 0 && errno == EINTR);
6353 6356
@@ -6435,7 +6438,7 @@ sigchld_handler (int signo)
6435 6438
6436 /* Report the status of the synchronous process. */ 6439 /* Report the status of the synchronous process. */
6437 if (WIFEXITED (w)) 6440 if (WIFEXITED (w))
6438 synch_process_retcode = WRETCODE (w); 6441 synch_process_retcode = WEXITSTATUS (w);
6439 else if (WIFSIGNALED (w)) 6442 else if (WIFSIGNALED (w))
6440 synch_process_termsig = WTERMSIG (w); 6443 synch_process_termsig = WTERMSIG (w);
6441 6444
@@ -6467,7 +6470,7 @@ sigchld_handler (int signo)
6467static Lisp_Object 6470static Lisp_Object
6468exec_sentinel_unwind (Lisp_Object data) 6471exec_sentinel_unwind (Lisp_Object data)
6469{ 6472{
6470 XPROCESS (XCAR (data))->sentinel = XCDR (data); 6473 PSET (XPROCESS (XCAR (data)), sentinel, XCDR (data));
6471 return Qnil; 6474 return Qnil;
6472} 6475}
6473 6476
@@ -6513,7 +6516,7 @@ exec_sentinel (Lisp_Object proc, Lisp_Object reason)
6513 6516
6514 /* Zilch the sentinel while it's running, to avoid recursive invocations; 6517 /* Zilch the sentinel while it's running, to avoid recursive invocations;
6515 assure that it gets restored no matter how the sentinel exits. */ 6518 assure that it gets restored no matter how the sentinel exits. */
6516 p->sentinel = Qnil; 6519 PSET (p, sentinel, Qnil);
6517 record_unwind_protect (exec_sentinel_unwind, Fcons (proc, sentinel)); 6520 record_unwind_protect (exec_sentinel_unwind, Fcons (proc, sentinel));
6518 /* Inhibit quit so that random quits don't screw up a running filter. */ 6521 /* Inhibit quit so that random quits don't screw up a running filter. */
6519 specbind (Qinhibit_quit, Qt); 6522 specbind (Qinhibit_quit, Qt);
@@ -6668,12 +6671,13 @@ status_notify (struct Lisp_Process *deleting_process)
6668 before_byte = PT_BYTE; 6671 before_byte = PT_BYTE;
6669 6672
6670 tem = BVAR (current_buffer, read_only); 6673 tem = BVAR (current_buffer, read_only);
6671 BVAR (current_buffer, read_only) = Qnil; 6674 BSET (current_buffer, read_only, Qnil);
6672 insert_string ("\nProcess "); 6675 insert_string ("\nProcess ");
6673 Finsert (1, &p->name); 6676 { /* FIXME: temporary kludge */
6677 Lisp_Object tem2 = p->name; Finsert (1, &tem2); }
6674 insert_string (" "); 6678 insert_string (" ");
6675 Finsert (1, &msg); 6679 Finsert (1, &msg);
6676 BVAR (current_buffer, read_only) = tem; 6680 BSET (current_buffer, read_only, tem);
6677 set_marker_both (p->mark, p->buffer, PT, PT_BYTE); 6681 set_marker_both (p->mark, p->buffer, PT, PT_BYTE);
6678 6682
6679 if (opoint >= before) 6683 if (opoint >= before)
@@ -6710,8 +6714,8 @@ encode subprocess input. */)
6710 Fcheck_coding_system (decoding); 6714 Fcheck_coding_system (decoding);
6711 Fcheck_coding_system (encoding); 6715 Fcheck_coding_system (encoding);
6712 encoding = coding_inherit_eol_type (encoding, Qnil); 6716 encoding = coding_inherit_eol_type (encoding, Qnil);
6713 p->decode_coding_system = decoding; 6717 PSET (p, decode_coding_system, decoding);
6714 p->encode_coding_system = encoding; 6718 PSET (p, encode_coding_system, encoding);
6715 setup_process_coding_systems (process); 6719 setup_process_coding_systems (process);
6716 6720
6717 return Qnil; 6721 return Qnil;
@@ -6741,7 +6745,8 @@ suppressed. */)
6741 CHECK_PROCESS (process); 6745 CHECK_PROCESS (process);
6742 p = XPROCESS (process); 6746 p = XPROCESS (process);
6743 if (NILP (flag)) 6747 if (NILP (flag))
6744 p->decode_coding_system = raw_text_coding_system (p->decode_coding_system); 6748 PSET (p, decode_coding_system,
6749 raw_text_coding_system (p->decode_coding_system));
6745 setup_process_coding_systems (process); 6750 setup_process_coding_systems (process);
6746 6751
6747 return Qnil; 6752 return Qnil;