diff options
| author | Stefan Monnier | 2011-02-01 12:09:25 -0500 |
|---|---|---|
| committer | Stefan Monnier | 2011-02-01 12:09:25 -0500 |
| commit | 8f1d2ef658f95549eb33fe5265f8f11c5129bece (patch) | |
| tree | b7cd852a1adb423384532cfe22c31547160b22bc /src/process.c | |
| parent | 590130fb19e1f433965c421d98fedeb2d7c33310 (diff) | |
| parent | 1dc4075fa8809805aed5092e93e225e889725c94 (diff) | |
| download | emacs-8f1d2ef658f95549eb33fe5265f8f11c5129bece.tar.gz emacs-8f1d2ef658f95549eb33fe5265f8f11c5129bece.zip | |
Merge from trunk
Diffstat (limited to 'src/process.c')
| -rw-r--r-- | src/process.c | 61 |
1 files changed, 23 insertions, 38 deletions
diff --git a/src/process.c b/src/process.c index 6ffcc5b8099..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, | 3 | Copyright (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 | ||
| 6 | This file is part of GNU Emacs. | 6 | This 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'. */ |
| @@ -123,9 +121,6 @@ Lisp_Object QCname, QCtype; | |||
| 123 | 121 | ||
| 124 | static int kbd_is_on_hold; | 122 | static int kbd_is_on_hold; |
| 125 | 123 | ||
| 126 | /* Nonzero means delete a process right away if it exits. */ | ||
| 127 | static int delete_exited_processes; | ||
| 128 | |||
| 129 | /* Nonzero means don't run process sentinels. This is used | 124 | /* Nonzero means don't run process sentinels. This is used |
| 130 | when exiting. */ | 125 | when exiting. */ |
| 131 | int inhibit_sentinels; | 126 | int inhibit_sentinels; |
| @@ -177,10 +172,6 @@ extern void serial_configure (struct Lisp_Process *p, Lisp_Object contact); | |||
| 177 | extern int h_errno; | 172 | extern int h_errno; |
| 178 | #endif | 173 | #endif |
| 179 | 174 | ||
| 180 | /* t means use pty, nil means use a pipe, | ||
| 181 | maybe other values to come. */ | ||
| 182 | static Lisp_Object Vprocess_connection_type; | ||
| 183 | |||
| 184 | /* 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 |
| 185 | emulation of `select'. */ | 176 | emulation of `select'. */ |
| 186 | /* Number of events of change of status of a process. */ | 177 | /* Number of events of change of status of a process. */ |
| @@ -249,11 +240,6 @@ static int process_output_delay_count; | |||
| 249 | 240 | ||
| 250 | static int process_output_skip; | 241 | static int process_output_skip; |
| 251 | 242 | ||
| 252 | /* Non-nil means to delay reading process output to improve buffering. | ||
| 253 | A value of t means that delay is reset after each send, any other | ||
| 254 | non-nil value does not reset the delay. A value of nil disables | ||
| 255 | adaptive read buffering completely. */ | ||
| 256 | static Lisp_Object Vprocess_adaptive_read_buffering; | ||
| 257 | #else | 243 | #else |
| 258 | #define process_output_delay_count 0 | 244 | #define process_output_delay_count 0 |
| 259 | #endif | 245 | #endif |
| @@ -425,7 +411,7 @@ delete_write_fd (int fd) | |||
| 425 | max_input_desc = fd; | 411 | max_input_desc = fd; |
| 426 | break; | 412 | break; |
| 427 | } | 413 | } |
| 428 | 414 | ||
| 429 | } | 415 | } |
| 430 | } | 416 | } |
| 431 | 417 | ||
| @@ -512,7 +498,7 @@ status_message (struct Lisp_Process *p) | |||
| 512 | if (! NILP (Vlocale_coding_system)) | 498 | if (! NILP (Vlocale_coding_system)) |
| 513 | string = (code_convert_string_norecord | 499 | string = (code_convert_string_norecord |
| 514 | (string, Vlocale_coding_system, 0)); | 500 | (string, Vlocale_coding_system, 0)); |
| 515 | c1 = STRING_CHAR ((char *) SDATA (string)); | 501 | c1 = STRING_CHAR (SDATA (string)); |
| 516 | c2 = DOWNCASE (c1); | 502 | c2 = DOWNCASE (c1); |
| 517 | if (c1 != c2) | 503 | if (c1 != c2) |
| 518 | Faset (string, make_number (0), make_number (c2)); | 504 | Faset (string, make_number (0), make_number (c2)); |
| @@ -1434,7 +1420,7 @@ list_processes_1 (Lisp_Object query_only) | |||
| 1434 | port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil); | 1420 | port = Fformat_network_address (Fplist_get (p->childp, QClocal), Qnil); |
| 1435 | sprintf (tembuf, "(network %s server on %s)\n", | 1421 | sprintf (tembuf, "(network %s server on %s)\n", |
| 1436 | (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), | 1422 | (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), |
| 1437 | (STRINGP (port) ? (char *)SDATA (port) : "?")); | 1423 | (STRINGP (port) ? SSDATA (port) : "?")); |
| 1438 | insert_string (tembuf); | 1424 | insert_string (tembuf); |
| 1439 | } | 1425 | } |
| 1440 | else if (NETCONN1_P (p)) | 1426 | else if (NETCONN1_P (p)) |
| @@ -1452,7 +1438,7 @@ list_processes_1 (Lisp_Object query_only) | |||
| 1452 | host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil); | 1438 | host = Fformat_network_address (Fplist_get (p->childp, QCremote), Qnil); |
| 1453 | sprintf (tembuf, "(network %s connection to %s)\n", | 1439 | sprintf (tembuf, "(network %s connection to %s)\n", |
| 1454 | (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), | 1440 | (DATAGRAM_CHAN_P (p->infd) ? "datagram" : "stream"), |
| 1455 | (STRINGP (host) ? (char *)SDATA (host) : "?")); | 1441 | (STRINGP (host) ? SSDATA (host) : "?")); |
| 1456 | insert_string (tembuf); | 1442 | insert_string (tembuf); |
| 1457 | } | 1443 | } |
| 1458 | else if (SERIALCONN1_P (p)) | 1444 | else if (SERIALCONN1_P (p)) |
| @@ -1461,7 +1447,7 @@ list_processes_1 (Lisp_Object query_only) | |||
| 1461 | Lisp_Object speed = Fplist_get (p->childp, QCspeed); | 1447 | Lisp_Object speed = Fplist_get (p->childp, QCspeed); |
| 1462 | insert_string ("(serial port "); | 1448 | insert_string ("(serial port "); |
| 1463 | if (STRINGP (port)) | 1449 | if (STRINGP (port)) |
| 1464 | insert_string (SDATA (port)); | 1450 | insert_string (SSDATA (port)); |
| 1465 | else | 1451 | else |
| 1466 | insert_string ("?"); | 1452 | insert_string ("?"); |
| 1467 | if (INTEGERP (speed)) | 1453 | if (INTEGERP (speed)) |
| @@ -2531,7 +2517,7 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val) | |||
| 2531 | 2517 | ||
| 2532 | CHECK_SYMBOL (opt); | 2518 | CHECK_SYMBOL (opt); |
| 2533 | 2519 | ||
| 2534 | name = (char *) SDATA (SYMBOL_NAME (opt)); | 2520 | name = SSDATA (SYMBOL_NAME (opt)); |
| 2535 | for (sopt = socket_options; sopt->name; sopt++) | 2521 | for (sopt = socket_options; sopt->name; sopt++) |
| 2536 | if (strcmp (name, sopt->name) == 0) | 2522 | if (strcmp (name, sopt->name) == 0) |
| 2537 | break; | 2523 | break; |
| @@ -2570,7 +2556,7 @@ set_socket_option (int s, Lisp_Object opt, Lisp_Object val) | |||
| 2570 | memset (devname, 0, sizeof devname); | 2556 | memset (devname, 0, sizeof devname); |
| 2571 | if (STRINGP (val)) | 2557 | if (STRINGP (val)) |
| 2572 | { | 2558 | { |
| 2573 | char *arg = (char *) SDATA (val); | 2559 | char *arg = SSDATA (val); |
| 2574 | int len = min (strlen (arg), IFNAMSIZ); | 2560 | int len = min (strlen (arg), IFNAMSIZ); |
| 2575 | memcpy (devname, arg, len); | 2561 | memcpy (devname, arg, len); |
| 2576 | } | 2562 | } |
| @@ -2855,7 +2841,7 @@ usage: (make-serial-process &rest ARGS) */) | |||
| 2855 | record_unwind_protect (make_serial_process_unwind, proc); | 2841 | record_unwind_protect (make_serial_process_unwind, proc); |
| 2856 | p = XPROCESS (proc); | 2842 | p = XPROCESS (proc); |
| 2857 | 2843 | ||
| 2858 | fd = serial_open ((char*) SDATA (port)); | 2844 | fd = serial_open (SSDATA (port)); |
| 2859 | p->infd = fd; | 2845 | p->infd = fd; |
| 2860 | p->outfd = fd; | 2846 | p->outfd = fd; |
| 2861 | if (fd > max_process_desc) | 2847 | if (fd > max_process_desc) |
| @@ -3276,7 +3262,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3276 | CHECK_STRING (service); | 3262 | CHECK_STRING (service); |
| 3277 | memset (&address_un, 0, sizeof address_un); | 3263 | memset (&address_un, 0, sizeof address_un); |
| 3278 | address_un.sun_family = AF_LOCAL; | 3264 | address_un.sun_family = AF_LOCAL; |
| 3279 | 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); |
| 3280 | ai.ai_addr = (struct sockaddr *) &address_un; | 3266 | ai.ai_addr = (struct sockaddr *) &address_un; |
| 3281 | ai.ai_addrlen = sizeof address_un; | 3267 | ai.ai_addrlen = sizeof address_un; |
| 3282 | goto open_socket; | 3268 | goto open_socket; |
| @@ -3312,7 +3298,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3312 | else | 3298 | else |
| 3313 | { | 3299 | { |
| 3314 | CHECK_STRING (service); | 3300 | CHECK_STRING (service); |
| 3315 | portstring = SDATA (service); | 3301 | portstring = SSDATA (service); |
| 3316 | } | 3302 | } |
| 3317 | 3303 | ||
| 3318 | immediate_quit = 1; | 3304 | immediate_quit = 1; |
| @@ -3327,12 +3313,12 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3327 | res_init (); | 3313 | res_init (); |
| 3328 | #endif | 3314 | #endif |
| 3329 | 3315 | ||
| 3330 | ret = getaddrinfo (SDATA (host), portstring, &hints, &res); | 3316 | ret = getaddrinfo (SSDATA (host), portstring, &hints, &res); |
| 3331 | if (ret) | 3317 | if (ret) |
| 3332 | #ifdef HAVE_GAI_STRERROR | 3318 | #ifdef HAVE_GAI_STRERROR |
| 3333 | error ("%s/%s %s", SDATA (host), portstring, gai_strerror (ret)); | 3319 | error ("%s/%s %s", SSDATA (host), portstring, gai_strerror (ret)); |
| 3334 | #else | 3320 | #else |
| 3335 | error ("%s/%s getaddrinfo error %d", SDATA (host), portstring, ret); | 3321 | error ("%s/%s getaddrinfo error %d", SSDATA (host), portstring, ret); |
| 3336 | #endif | 3322 | #endif |
| 3337 | immediate_quit = 0; | 3323 | immediate_quit = 0; |
| 3338 | 3324 | ||
| @@ -3351,7 +3337,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3351 | { | 3337 | { |
| 3352 | struct servent *svc_info; | 3338 | struct servent *svc_info; |
| 3353 | CHECK_STRING (service); | 3339 | CHECK_STRING (service); |
| 3354 | svc_info = getservbyname (SDATA (service), | 3340 | svc_info = getservbyname (SSDATA (service), |
| 3355 | (socktype == SOCK_DGRAM ? "udp" : "tcp")); | 3341 | (socktype == SOCK_DGRAM ? "udp" : "tcp")); |
| 3356 | if (svc_info == 0) | 3342 | if (svc_info == 0) |
| 3357 | error ("Unknown service: %s", SDATA (service)); | 3343 | error ("Unknown service: %s", SDATA (service)); |
| @@ -3391,7 +3377,7 @@ usage: (make-network-process &rest ARGS) */) | |||
| 3391 | /* Attempt to interpret host as numeric inet address */ | 3377 | /* Attempt to interpret host as numeric inet address */ |
| 3392 | { | 3378 | { |
| 3393 | unsigned long numeric_addr; | 3379 | unsigned long numeric_addr; |
| 3394 | numeric_addr = inet_addr ((char *) SDATA (host)); | 3380 | numeric_addr = inet_addr (SSDATA (host)); |
| 3395 | if (numeric_addr == -1) | 3381 | if (numeric_addr == -1) |
| 3396 | error ("Unknown host \"%s\"", SDATA (host)); | 3382 | error ("Unknown host \"%s\"", SDATA (host)); |
| 3397 | 3383 | ||
| @@ -5659,7 +5645,7 @@ send_process (volatile Lisp_Object proc, const unsigned char *volatile buf, | |||
| 5659 | #ifdef HAVE_GNUTLS | 5645 | #ifdef HAVE_GNUTLS |
| 5660 | if (XPROCESS (proc)->gnutls_p) | 5646 | if (XPROCESS (proc)->gnutls_p) |
| 5661 | rv = emacs_gnutls_write (outfd, | 5647 | rv = emacs_gnutls_write (outfd, |
| 5662 | XPROCESS (proc), | 5648 | XPROCESS (proc), |
| 5663 | (char *) buf, this); | 5649 | (char *) buf, this); |
| 5664 | else | 5650 | else |
| 5665 | #endif | 5651 | #endif |
| @@ -5821,7 +5807,7 @@ emacs_get_tty_pgrp (struct Lisp_Process *p) | |||
| 5821 | int fd; | 5807 | int fd; |
| 5822 | /* 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 |
| 5823 | master side. Try the slave side. */ | 5809 | master side. Try the slave side. */ |
| 5824 | fd = emacs_open (SDATA (p->tty_name), O_RDONLY, 0); | 5810 | fd = emacs_open (SSDATA (p->tty_name), O_RDONLY, 0); |
| 5825 | 5811 | ||
| 5826 | if (fd != -1) | 5812 | if (fd != -1) |
| 5827 | { | 5813 | { |
| @@ -7644,14 +7630,14 @@ syms_of_process (void) | |||
| 7644 | Qargs = intern_c_string ("args"); | 7630 | Qargs = intern_c_string ("args"); |
| 7645 | staticpro (&Qargs); | 7631 | staticpro (&Qargs); |
| 7646 | 7632 | ||
| 7647 | DEFVAR_BOOL ("delete-exited-processes", &delete_exited_processes, | 7633 | DEFVAR_BOOL ("delete-exited-processes", delete_exited_processes, |
| 7648 | doc: /* *Non-nil means delete processes immediately when they exit. | 7634 | doc: /* *Non-nil means delete processes immediately when they exit. |
| 7649 | A value of nil means don't delete them until `list-processes' is run. */); | 7635 | A value of nil means don't delete them until `list-processes' is run. */); |
| 7650 | 7636 | ||
| 7651 | delete_exited_processes = 1; | 7637 | delete_exited_processes = 1; |
| 7652 | 7638 | ||
| 7653 | #ifdef subprocesses | 7639 | #ifdef subprocesses |
| 7654 | DEFVAR_LISP ("process-connection-type", &Vprocess_connection_type, | 7640 | DEFVAR_LISP ("process-connection-type", Vprocess_connection_type, |
| 7655 | doc: /* Control type of device used to communicate with subprocesses. | 7641 | doc: /* Control type of device used to communicate with subprocesses. |
| 7656 | Values are nil to use a pipe, or t or `pty' to use a pty. | 7642 | Values are nil to use a pipe, or t or `pty' to use a pty. |
| 7657 | The value has no effect if the system has no ptys or if all ptys are busy: | 7643 | The value has no effect if the system has no ptys or if all ptys are busy: |
| @@ -7660,7 +7646,7 @@ The value takes effect when `start-process' is called. */); | |||
| 7660 | Vprocess_connection_type = Qt; | 7646 | Vprocess_connection_type = Qt; |
| 7661 | 7647 | ||
| 7662 | #ifdef ADAPTIVE_READ_BUFFERING | 7648 | #ifdef ADAPTIVE_READ_BUFFERING |
| 7663 | DEFVAR_LISP ("process-adaptive-read-buffering", &Vprocess_adaptive_read_buffering, | 7649 | DEFVAR_LISP ("process-adaptive-read-buffering", Vprocess_adaptive_read_buffering, |
| 7664 | 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. |
| 7665 | On some systems, when Emacs reads the output from a subprocess, the output data | 7651 | On some systems, when Emacs reads the output from a subprocess, the output data |
| 7666 | is read in very small blocks, potentially resulting in very poor performance. | 7652 | is read in very small blocks, potentially resulting in very poor performance. |
| @@ -7741,4 +7727,3 @@ The variable takes effect when `start-process' is called. */); | |||
| 7741 | defsubr (&Slist_system_processes); | 7727 | defsubr (&Slist_system_processes); |
| 7742 | defsubr (&Sprocess_attributes); | 7728 | defsubr (&Sprocess_attributes); |
| 7743 | } | 7729 | } |
| 7744 | |||