aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorJoakim Verona2011-02-05 11:23:09 +0100
committerJoakim Verona2011-02-05 11:23:09 +0100
commit4bd51ad5c3445b644dfb017d5b57b10a90aa325f (patch)
tree894801e7308ce4ecc34933f959e28f4b9cff9533 /src/process.c
parent13cfe8df462ab8da9f0028e16cc84dcaceaca3d1 (diff)
parent9bcaafce5351d270ac514e23cb69ff1a5fd35229 (diff)
downloademacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.tar.gz
emacs-4bd51ad5c3445b644dfb017d5b57b10a90aa325f.zip
merge from upstream. currently seems to have bitroted and i get segfaults
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c75
1 files changed, 27 insertions, 48 deletions
diff --git a/src/process.c b/src/process.c
index e1515065957..ca29145bfd4 100644
--- a/src/process.c
+++ b/src/process.c
@@ -1,7 +1,7 @@
1/* Asynchronous subprocess control for GNU Emacs. 1/* Asynchronous subprocess control for GNU Emacs.
2 Copyright (C) 1985, 1986, 1987, 1988, 1993, 1994, 1995, 2
3 1996, 1998, 1999, 2001, 2002, 2003, 2004, 3Copyright (C) 1985-1988, 1993-1996, 1998-1999, 2001-2011
4 2005, 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 4 Free Software Foundation, Inc.
5 5
6This file is part of GNU Emacs. 6This file is part of GNU Emacs.
7 7
@@ -32,9 +32,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
32#include <inttypes.h> 32#include <inttypes.h>
33#endif 33#endif
34 34
35#ifdef HAVE_UNISTD_H
36#include <unistd.h> 35#include <unistd.h>
37#endif
38#include <fcntl.h> 36#include <fcntl.h>
39 37
40/* Only MS-DOS does not define `subprocesses'. */ 38/* Only MS-DOS does not define `subprocesses'. */
@@ -56,12 +54,10 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
56#endif 54#endif
57#endif 55#endif
58 56
59#if defined(HAVE_SYS_IOCTL_H)
60#include <sys/ioctl.h> 57#include <sys/ioctl.h>
61#if defined(HAVE_NET_IF_H) 58#if defined(HAVE_NET_IF_H)
62#include <net/if.h> 59#include <net/if.h>
63#endif /* HAVE_NET_IF_H */ 60#endif /* HAVE_NET_IF_H */
64#endif /* HAVE_SYS_IOCTL_H */
65 61
66#ifdef NEED_BSDTTY 62#ifdef NEED_BSDTTY
67#include <bsdtty.h> 63#include <bsdtty.h>
@@ -115,8 +111,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */
115#include "nsterm.h" 111#include "nsterm.h"
116#endif 112#endif
117 113
118extern int timers_run;
119
120Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid; 114Lisp_Object Qeuid, Qegid, Qcomm, Qstate, Qppid, Qpgrp, Qsess, Qttname, Qtpgid;
121Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime; 115Lisp_Object Qminflt, Qmajflt, Qcminflt, Qcmajflt, Qutime, Qstime, Qcstime;
122Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs; 116Lisp_Object Qcutime, Qpri, Qnice, Qthcount, Qstart, Qvsize, Qrss, Qargs;
@@ -127,9 +121,6 @@ Lisp_Object QCname, QCtype;
127 121
128static int kbd_is_on_hold; 122static int kbd_is_on_hold;
129 123
130/* Nonzero means delete a process right away if it exits. */
131static int delete_exited_processes;
132
133/* Nonzero means don't run process sentinels. This is used 124/* Nonzero means don't run process sentinels. This is used
134 when exiting. */ 125 when exiting. */
135int inhibit_sentinels; 126int inhibit_sentinels;
@@ -181,10 +172,6 @@ extern void serial_configure (struct Lisp_Process *p, Lisp_Object contact);
181extern int h_errno; 172extern int h_errno;
182#endif 173#endif
183 174
184/* t means use pty, nil means use a pipe,
185 maybe other values to come. */
186static Lisp_Object Vprocess_connection_type;
187
188/* These next two vars are non-static since sysdep.c uses them in the 175/* These next two vars are non-static since sysdep.c uses them in the
189 emulation of `select'. */ 176 emulation of `select'. */
190/* Number of events of change of status of a process. */ 177/* Number of events of change of status of a process. */
@@ -253,11 +240,6 @@ static int process_output_delay_count;
253 240
254static int process_output_skip; 241static int process_output_skip;
255 242
256/* Non-nil means to delay reading process output to improve buffering.
257 A value of t means that delay is reset after each send, any other
258 non-nil value does not reset the delay. A value of nil disables
259 adaptive read buffering completely. */
260static Lisp_Object Vprocess_adaptive_read_buffering;
261#else 243#else
262#define process_output_delay_count 0 244#define process_output_delay_count 0
263#endif 245#endif
@@ -429,7 +411,7 @@ delete_write_fd (int fd)
429 max_input_desc = fd; 411 max_input_desc = fd;
430 break; 412 break;
431 } 413 }
432 414
433 } 415 }
434} 416}
435 417
@@ -516,7 +498,7 @@ status_message (struct Lisp_Process *p)
516 if (! NILP (Vlocale_coding_system)) 498 if (! NILP (Vlocale_coding_system))
517 string = (code_convert_string_norecord 499 string = (code_convert_string_norecord
518 (string, Vlocale_coding_system, 0)); 500 (string, Vlocale_coding_system, 0));
519 c1 = STRING_CHAR ((char *) SDATA (string)); 501 c1 = STRING_CHAR (SDATA (string));
520 c2 = DOWNCASE (c1); 502 c2 = DOWNCASE (c1);
521 if (c1 != c2) 503 if (c1 != c2)
522 Faset (string, make_number (0), make_number (c2)); 504 Faset (string, make_number (0), make_number (c2));
@@ -1438,7 +1420,7 @@ list_processes_1 (Lisp_Object query_only)
1438 port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil); 1420 port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil);
1439 sprintf (tembuf, "(network %s server on %s)\n", 1421 sprintf (tembuf, "(network %s server on %s)\n",
1440 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), 1422 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
1441 (STRINGP (port) ? (char *)SDATA (port) : "?")); 1423 (STRINGP (port) ? SSDATA (port) : "?"));
1442 insert_string (tembuf); 1424 insert_string (tembuf);
1443 } 1425 }
1444 else if (NETCONN1_P (p)) 1426 else if (NETCONN1_P (p))
@@ -1456,7 +1438,7 @@ list_processes_1 (Lisp_Object query_only)
1456 host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil); 1438 host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil);
1457 sprintf (tembuf, "(network %s connection to %s)\n", 1439 sprintf (tembuf, "(network %s connection to %s)\n",
1458 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), 1440 (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"),
1459 (STRINGP (host) ? (char *)SDATA (host) : "?")); 1441 (STRINGP (host) ? SSDATA (host) : "?"));
1460 insert_string (tembuf); 1442 insert_string (tembuf);
1461 } 1443 }
1462 else if (SERIALCONN1_P (p)) 1444 else if (SERIALCONN1_P (p))
@@ -1465,7 +1447,7 @@ list_processes_1 (Lisp_Object query_only)
1465 Lisp_Object speed = Fplist_get (p->childp, QCspeed); 1447 Lisp_Object speed = Fplist_get (p->childp, QCspeed);
1466 insert_string ("(serial port "); 1448 insert_string ("(serial port ");
1467 if (STRINGP (port)) 1449 if (STRINGP (port))
1468 insert_string (SDATA (port)); 1450 insert_string (SSDATA (port));
1469 else 1451 else
1470 insert_string ("?"); 1452 insert_string ("?");
1471 if (INTEGERP (speed)) 1453 if (INTEGERP (speed))
@@ -2535,7 +2517,7 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val)
2535 2517
2536 CHECK_SYMBOL (opt); 2518 CHECK_SYMBOL (opt);
2537 2519
2538 name = (char *) SDATA (SYMBOL_NAME (opt)); 2520 name = SSDATA (SYMBOL_NAME (opt));
2539 for (sopt = socket_options; sopt->name; sopt++) 2521 for (sopt = socket_options; sopt->name; sopt++)
2540 if (strcmp (name, sopt->name) == 0) 2522 if (strcmp (name, sopt->name) == 0)
2541 break; 2523 break;
@@ -2574,7 +2556,7 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val)
2574 memset (devname, 0, sizeof devname); 2556 memset (devname, 0, sizeof devname);
2575 if (STRINGP (val)) 2557 if (STRINGP (val))
2576 { 2558 {
2577 char *arg = (char *) SDATA (val); 2559 char *arg = SSDATA (val);
2578 int len = min (strlen (arg), IFNAMSIZ); 2560 int len = min (strlen (arg), IFNAMSIZ);
2579 memcpy (devname, arg, len); 2561 memcpy (devname, arg, len);
2580 } 2562 }
@@ -2859,7 +2841,7 @@ usage: (make-serial-process &rest ARGS) */)
2859 record_unwind_protect (make_serial_process_unwind, proc); 2841 record_unwind_protect (make_serial_process_unwind, proc);
2860 p = XPROCESS (proc); 2842 p = XPROCESS (proc);
2861 2843
2862 fd = serial_open ((char*) SDATA (port)); 2844 fd = serial_open (SSDATA (port));
2863 p->infd = fd; 2845 p->infd = fd;
2864 p->outfd = fd; 2846 p->outfd = fd;
2865 if (fd > max_process_desc) 2847 if (fd > max_process_desc)
@@ -3280,7 +3262,7 @@ usage: (make-network-process &rest ARGS) */)
3280 CHECK_STRING (service); 3262 CHECK_STRING (service);
3281 memset (&address_un, 0, sizeof address_un); 3263 memset (&address_un, 0, sizeof address_un);
3282 address_un.sun_family = AF_LOCAL; 3264 address_un.sun_family = AF_LOCAL;
3283 strncpy (address_un.sun_path, SDATA (service), sizeof address_un.sun_path); 3265 strncpy (address_un.sun_path, SSDATA (service), sizeof address_un.sun_path);
3284 ai.ai_addr = (struct sockaddr *) &address_un; 3266 ai.ai_addr = (struct sockaddr *) &address_un;
3285 ai.ai_addrlen = sizeof address_un; 3267 ai.ai_addrlen = sizeof address_un;
3286 goto open_socket; 3268 goto open_socket;
@@ -3316,7 +3298,7 @@ usage: (make-network-process &rest ARGS) */)
3316 else 3298 else
3317 { 3299 {
3318 CHECK_STRING (service); 3300 CHECK_STRING (service);
3319 portstring = SDATA (service); 3301 portstring = SSDATA (service);
3320 } 3302 }
3321 3303
3322 immediate_quit = 1; 3304 immediate_quit = 1;
@@ -3331,12 +3313,12 @@ usage: (make-network-process &rest ARGS) */)
3331 res_init (); 3313 res_init ();
3332#endif 3314#endif
3333 3315
3334 ret = getaddrinfo (SDATA (host), portstring, &hints, &res); 3316 ret = getaddrinfo (SSDATA (host), portstring, &hints, &res);
3335 if (ret) 3317 if (ret)
3336#ifdef HAVE_GAI_STRERROR 3318#ifdef HAVE_GAI_STRERROR
3337 error ("%s/%s %s", SDATA (host), portstring, gai_strerror (ret)); 3319 error ("%s/%s %s", SSDATA (host), portstring, gai_strerror (ret));
3338#else 3320#else
3339 error ("%s/%s getaddrinfo error %d", SDATA (host), portstring, ret); 3321 error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret);
3340#endif 3322#endif
3341 immediate_quit = 0; 3323 immediate_quit = 0;
3342 3324
@@ -3355,7 +3337,7 @@ usage: (make-network-process &rest ARGS) */)
3355 { 3337 {
3356 struct servent *svc_info; 3338 struct servent *svc_info;
3357 CHECK_STRING (service); 3339 CHECK_STRING (service);
3358 svc_info = getservbyname (SDATA (service), 3340 svc_info = getservbyname (SSDATA (service),
3359 (socktype == SOCK_DGRAM ? "udp" : "tcp")); 3341 (socktype == SOCK_DGRAM ? "udp" : "tcp"));
3360 if (svc_info == 0) 3342 if (svc_info == 0)
3361 error ("Unknown service: %s", SDATA (service)); 3343 error ("Unknown service: %s", SDATA (service));
@@ -3395,7 +3377,7 @@ usage: (make-network-process &rest ARGS) */)
3395 /* Attempt to interpret host as numeric inet address */ 3377 /* Attempt to interpret host as numeric inet address */
3396 { 3378 {
3397 unsigned long numeric_addr; 3379 unsigned long numeric_addr;
3398 numeric_addr = inet_addr ((char *) SDATA (host)); 3380 numeric_addr = inet_addr (SSDATA (host));
3399 if (numeric_addr == -1) 3381 if (numeric_addr == -1)
3400 error ("Unknown host \"%s\"", SDATA (host)); 3382 error ("Unknown host \"%s\"", SDATA (host));
3401 3383
@@ -3811,7 +3793,7 @@ usage: (make-network-process &rest ARGS) */)
3811} 3793}
3812 3794
3813 3795
3814#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) 3796#if defined(HAVE_NET_IF_H)
3815 3797
3816#ifdef SIOCGIFCONF 3798#ifdef SIOCGIFCONF
3817DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0, 3799DEFUN ("network-interface-list", Fnetwork_interface_list, Snetwork_interface_list, 0, 0, 0,
@@ -4054,7 +4036,7 @@ FLAGS is the current flags of the interface. */)
4054 return any ? res : Qnil; 4036 return any ? res : Qnil;
4055} 4037}
4056#endif 4038#endif
4057#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */ 4039#endif /* defined(HAVE_NET_IF_H) */
4058 4040
4059/* Turn off input and output for process PROC. */ 4041/* Turn off input and output for process PROC. */
4060 4042
@@ -5663,7 +5645,7 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf,
5663#ifdef HAVE_GNUTLS 5645#ifdef HAVE_GNUTLS
5664 if (XPROCESS (proc)->gnutls_p) 5646 if (XPROCESS (proc)->gnutls_p)
5665 rv = emacs_gnutls_write (outfd, 5647 rv = emacs_gnutls_write (outfd,
5666 XPROCESS (proc), 5648 XPROCESS (proc),
5667 (char *) buf, this); 5649 (char *) buf, this);
5668 else 5650 else
5669#endif 5651#endif
@@ -5825,7 +5807,7 @@ emacs_get_tty_pgrp (struct Lisp_Process *p)
5825 int fd; 5807 int fd;
5826 /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the 5808 /* Some OS:es (Solaris 8/9) does not allow TIOCGPGRP from the
5827 master side. Try the slave side. */ 5809 master side. Try the slave side. */
5828 fd = emacs_open (SDATA (p->tty_name), O_RDONLY, 0); 5810 fd = emacs_open (SSDATA (p->tty_name), O_RDONLY, 0);
5829 5811
5830 if (fd != -1) 5812 if (fd != -1)
5831 { 5813 {
@@ -7648,14 +7630,14 @@ syms_of_process (void)
7648 Qargs = intern_c_string ("args"); 7630 Qargs = intern_c_string ("args");
7649 staticpro (&Qargs); 7631 staticpro (&Qargs);
7650 7632
7651 DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, 7633 DEFVAR_BOOL ("delete-exited-processes", delete_exited_processes,
7652 doc: /* *Non-nil means delete processes immediately when they exit. 7634 doc: /* *Non-nil means delete processes immediately when they exit.
7653A value of nil means don't delete them until `list-processes' is run. */); 7635A value of nil means don't delete them until `list-processes' is run. */);
7654 7636
7655 delete_exited_processes = 1; 7637 delete_exited_processes = 1;
7656 7638
7657#ifdef subprocesses 7639#ifdef subprocesses
7658 DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type, 7640 DEFVAR_LISP ("process-connection-type", Vprocess_connection_type,
7659 doc: /* Control type of device used to communicate with subprocesses. 7641 doc: /* Control type of device used to communicate with subprocesses.
7660Values are nil to use a pipe, or t or `pty' to use a pty. 7642Values are nil to use a pipe, or t or `pty' to use a pty.
7661The value has no effect if the system has no ptys or if all ptys are busy: 7643The value has no effect if the system has no ptys or if all ptys are busy:
@@ -7664,7 +7646,7 @@ The value takes effect when `start-process' is called. */);
7664 Vprocess_connection_type = Qt; 7646 Vprocess_connection_type = Qt;
7665 7647
7666#ifdef ADAPTIVE_READ_BUFFERING 7648#ifdef ADAPTIVE_READ_BUFFERING
7667 DEFVAR_LISP ("process-adaptive-read-buffering", &Vprocess_adaptive_read_buffering, 7649 DEFVAR_LISP ("process-adaptive-read-buffering", Vprocess_adaptive_read_buffering,
7668 doc: /* If non-nil, improve receive buffering by delaying after short reads. 7650 doc: /* If non-nil, improve receive buffering by delaying after short reads.
7669On some systems, when Emacs reads the output from a subprocess, the output data 7651On some systems, when Emacs reads the output from a subprocess, the output data
7670is read in very small blocks, potentially resulting in very poor performance. 7652is read in very small blocks, potentially resulting in very poor performance.
@@ -7708,14 +7690,14 @@ The variable takes effect when `start-process' is called. */);
7708 defsubr (&Sset_network_process_option); 7690 defsubr (&Sset_network_process_option);
7709 defsubr (&Smake_network_process); 7691 defsubr (&Smake_network_process);
7710 defsubr (&Sformat_network_address); 7692 defsubr (&Sformat_network_address);
7711#if defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) 7693#if defined(HAVE_NET_IF_H)
7712#ifdef SIOCGIFCONF 7694#ifdef SIOCGIFCONF
7713 defsubr (&Snetwork_interface_list); 7695 defsubr (&Snetwork_interface_list);
7714#endif 7696#endif
7715#if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS) 7697#if defined(SIOCGIFADDR) || defined(SIOCGIFHWADDR) || defined(SIOCGIFFLAGS)
7716 defsubr (&Snetwork_interface_info); 7698 defsubr (&Snetwork_interface_info);
7717#endif 7699#endif
7718#endif /* defined(HAVE_NET_IF_H) && defined(HAVE_SYS_IOCTL_H) */ 7700#endif /* defined(HAVE_NET_IF_H) */
7719#ifdef DATAGRAM_SOCKETS 7701#ifdef DATAGRAM_SOCKETS
7720 defsubr (&Sprocess_datagram_address); 7702 defsubr (&Sprocess_datagram_address);
7721 defsubr (&Sset_process_datagram_address); 7703 defsubr (&Sset_process_datagram_address);
@@ -7745,6 +7727,3 @@ The variable takes effect when `start-process' is called. */);
7745 defsubr (&Slist_system_processes); 7727 defsubr (&Slist_system_processes);
7746 defsubr (&Sprocess_attributes); 7728 defsubr (&Sprocess_attributes);
7747} 7729}
7748
7749/* arch-tag: 3706c011-7b9a-4117-bd4f-59e7f701a4c4
7750 (do not change this comment) */