comparison lispref/processes.texi @ 90114:e4694597cbf4

Revision: miles@gnu.org--gnu-2005/emacs--unicode--0--patch-21 Merge from emacs--cvs-trunk--0 Patches applied: * miles@gnu.org--gnu-2005/emacs--cvs-trunk--0 (patch 129-149) - Update from CVS - Merge from gnus--rel--5.10 - (make-text-button): Default button type if not specified - quick-install-emacs: Use mkdir --verbose only when requested * miles@gnu.org--gnu-2005/gnus--rel--5.10 (patch 31-33) - Merge from emacs--cvs-trunk--0 - Update from CVS
author Miles Bader <miles@gnu.org>
date Thu, 03 Mar 2005 10:35:22 +0000
parents 3ebd9bdb4fe5 b87ad571b7a8
children 62afea0771d8
comparison
equal deleted inserted replaced
90113:a50413a4ba8b 90114:e4694597cbf4
75 program to be run. An error is signaled if the file is not found or 75 program to be run. An error is signaled if the file is not found or
76 cannot be executed. If the file name is relative, the variable 76 cannot be executed. If the file name is relative, the variable
77 @code{exec-path} contains a list of directories to search. Emacs 77 @code{exec-path} contains a list of directories to search. Emacs
78 initializes @code{exec-path} when it starts up, based on the value of 78 initializes @code{exec-path} when it starts up, based on the value of
79 the environment variable @code{PATH}. The standard file name 79 the environment variable @code{PATH}. The standard file name
80 constructs, @samp{~}, @samp{.}, and @samp{..}, are interpreted as usual 80 constructs, @samp{~}, @samp{.}, and @samp{..}, are interpreted as
81 in @code{exec-path}, but environment variable substitutions 81 usual in @code{exec-path}, but environment variable substitutions
82 (@samp{$HOME}, etc.) are not recognized; use 82 (@samp{$HOME}, etc.) are not recognized; use
83 @code{substitute-in-file-name} to perform them (@pxref{File Name 83 @code{substitute-in-file-name} to perform them (@pxref{File Name
84 Expansion}). 84 Expansion}). @code{nil} in this list refers to
85 @code{default-directory}.
85 86
86 Executing a program can also try adding suffixes to the specified 87 Executing a program can also try adding suffixes to the specified
87 name: 88 name:
88 89
89 @defvar exec-suffixes 90 @defvar exec-suffixes
90 This variable is a list of suffixes (strings) to try adding to the 91 This variable is a list of suffixes (strings) to try adding to the
91 specified program file name. The list should include @code{""} if you 92 specified program file name. The list should include @code{""} if you
92 want the name to be tried exactly as specified. The default value is 93 want the name to be tried exactly as specified. The default value is
93 system-dependent. 94 system-dependent.
94 @end defvar 95 @end defvar
96
97 @strong{Please note:} The argument @var{program} contains only the
98 name of the program; it may not contain any command-line arguments. You
99 must use @var{args} to provide those.
95 100
96 Each of the subprocess-creating functions has a @var{buffer-or-name} 101 Each of the subprocess-creating functions has a @var{buffer-or-name}
97 argument which specifies where the standard output from the program will 102 argument which specifies where the standard output from the program will
98 go. It should be a buffer or a buffer name; if it is a buffer name, 103 go. It should be a buffer or a buffer name; if it is a buffer name,
99 that will create the buffer if it does not already exist. It can also 104 that will create the buffer if it does not already exist. It can also
105 @cindex program arguments 110 @cindex program arguments
106 All three of the subprocess-creating functions have a @code{&rest} 111 All three of the subprocess-creating functions have a @code{&rest}
107 argument, @var{args}. The @var{args} must all be strings, and they are 112 argument, @var{args}. The @var{args} must all be strings, and they are
108 supplied to @var{program} as separate command line arguments. Wildcard 113 supplied to @var{program} as separate command line arguments. Wildcard
109 characters and other shell constructs have no special meanings in these 114 characters and other shell constructs have no special meanings in these
110 strings, since the whole strings are passed directly to the specified 115 strings, since the strings are passed directly to the specified program.
111 program.
112
113 @strong{Please note:} The argument @var{program} contains only the
114 name of the program; it may not contain any command-line arguments. You
115 must use @var{args} to provide those.
116 116
117 The subprocess gets its current directory from the value of 117 The subprocess gets its current directory from the value of
118 @code{default-directory} (@pxref{File Name Expansion}). 118 @code{default-directory} (@pxref{File Name Expansion}).
119 119
120 @cindex environment variables, subprocesses 120 @cindex environment variables, subprocesses
545 545
546 @dfn{Deleting a process} disconnects Emacs immediately from the 546 @dfn{Deleting a process} disconnects Emacs immediately from the
547 subprocess. Processes are deleted automatically after they terminate, 547 subprocess. Processes are deleted automatically after they terminate,
548 but not necessarily right away. You can delete a process explicitly 548 but not necessarily right away. You can delete a process explicitly
549 at any time. If you delete a terminated process explicitly before it 549 at any time. If you delete a terminated process explicitly before it
550 is deleted automatically, no harm results. Deletion of a running 550 is deleted automatically, no harm results. Deleting a running
551 process sends a signal to terminate it (and its child processes if 551 process sends a signal to terminate it (and its child processes if
552 any), and calls the process sentinel if it has one. 552 any), and calls the process sentinel if it has one. @xref{Sentinels}.
553 553
554 @code{get-buffer-process} and @code{process-list} do not remember a 554 When a process is deleted, the process object itself continues to
555 deleted process, but the process object itself continues to exist as 555 exist as long as other Lisp objects point to it. All the Lisp
556 long as other Lisp objects point to it. All the Lisp primitives that 556 primitives that work on process objects accept deleted processes, but
557 work on process objects accept deleted processes, but those that do 557 those that do I/O or send signals will report an error. The process
558 I/O or send signals will report an error. The process mark continues 558 mark continues to point to the same place as before, usually into a
559 to point to the same place as before, usually into a buffer where 559 buffer where output from the process was being inserted.
560 output from the process was being inserted.
561 560
562 @defopt delete-exited-processes 561 @defopt delete-exited-processes
563 This variable controls automatic deletion of processes that have 562 This variable controls automatic deletion of processes that have
564 terminated (due to calling @code{exit} or to a signal). If it is 563 terminated (due to calling @code{exit} or to a signal). If it is
565 @code{nil}, then they continue to exist until the user runs 564 @code{nil}, then they continue to exist until the user runs
566 @code{list-processes}. Otherwise, they are deleted immediately after 565 @code{list-processes}. Otherwise, they are deleted immediately after
567 they exit. 566 they exit.
568 @end defopt 567 @end defopt
569 568
570 @defun delete-process name 569 @defun delete-process process
571 This function deletes the process associated with @var{name}, killing 570 This function deletes a process, killing it with a @code{SIGKILL}
572 it with a @code{SIGKILL} signal. The argument @var{name} may be a 571 signal. The argument may be a process, the name of a process, a
573 process, the name of a process, a buffer, or the name of a buffer. 572 buffer, or the name of a buffer. (A buffer or buffer-name stands for
574 Calling @code{delete-process} on a running process terminates it, 573 the process that @code{get-buffer-process} returns.) Calling
575 updates the process status, and runs the sentinel (if any) immediately. 574 @code{delete-process} on a running process terminates it, updates the
576 If the process has already terminated, calling @code{delete-process} 575 process status, and runs the sentinel (if any) immediately. If the
577 has no effect on its status, or on the running of its sentinel (which 576 process has already terminated, calling @code{delete-process} has no
578 will happen sooner or later). 577 effect on its status, or on the running of its sentinel (which will
578 happen sooner or later).
579 579
580 @smallexample 580 @smallexample
581 @group 581 @group
582 (delete-process "*shell*") 582 (delete-process "*shell*")
583 @result{} nil 583 @result{} nil
726 @example 726 @example
727 (@var{coding-system-for-decoding} . @var{coding-system-for-encoding}) 727 (@var{coding-system-for-decoding} . @var{coding-system-for-encoding})
728 @end example 728 @end example
729 @end defun 729 @end defun
730 730
731 @defun set-process-coding-system process decoding-system encoding-system 731 @defun set-process-coding-system process &optional decoding-system encoding-system
732 This function specifies the coding systems to use for subsequent output 732 This function specifies the coding systems to use for subsequent output
733 from and input to @var{process}. It will use @var{decoding-system} to 733 from and input to @var{process}. It will use @var{decoding-system} to
734 decode subprocess output, and @var{encoding-system} to encode subprocess 734 decode subprocess output, and @var{encoding-system} to encode subprocess
735 input. 735 input.
736 @end defun 736 @end defun
782 wait a short while, accepting output from subprocesses, and then try 782 wait a short while, accepting output from subprocesses, and then try
783 again. This gives the subprocess a chance to read more of its pending 783 again. This gives the subprocess a chance to read more of its pending
784 input and make space in the buffer. It also allows filters, sentinels 784 input and make space in the buffer. It also allows filters, sentinels
785 and timers to run---so take account of that in writing your code. 785 and timers to run---so take account of that in writing your code.
786 786
787 @defun process-send-string process-name string 787 In these functions, the @var{process} argument can be a process or
788 This function sends @var{process-name} the contents of @var{string} as 788 the name of a process, or a buffer or buffer name (which stands
789 standard input. The argument @var{process-name} must be a process or 789 for a process via @code{get-buffer-process}). @code{nil} means
790 the name of a process. If it is @code{nil}, the current buffer's 790 the current buffer's process.
791 process is used. 791
792 @defun process-send-string process string
793 This function sends @var{process} the contents of @var{string} as
794 standard input. If it is @code{nil}, the current buffer's process is used.
792 795
793 The function returns @code{nil}. 796 The function returns @code{nil}.
794 797
795 @smallexample 798 @smallexample
796 @group 799 @group
809 ---------- Buffer: *shell* ---------- 812 ---------- Buffer: *shell* ----------
810 @end group 813 @end group
811 @end smallexample 814 @end smallexample
812 @end defun 815 @end defun
813 816
814 @defun process-send-region process-name start end 817 @defun process-send-region process start end
815 This function sends the text in the region defined by @var{start} and 818 This function sends the text in the region defined by @var{start} and
816 @var{end} as standard input to @var{process-name}, which is a process or 819 @var{end} as standard input to @var{process}.
817 a process name. (If it is @code{nil}, the current buffer's process is
818 used.)
819 820
820 An error is signaled unless both @var{start} and @var{end} are 821 An error is signaled unless both @var{start} and @var{end} are
821 integers or markers that indicate positions in the current buffer. (It 822 integers or markers that indicate positions in the current buffer. (It
822 is unimportant which number is larger.) 823 is unimportant which number is larger.)
823 @end defun 824 @end defun
824 825
825 @defun process-send-eof &optional process-name 826 @defun process-send-eof &optional process
826 This function makes @var{process-name} see an end-of-file in its 827 This function makes @var{process} see an end-of-file in its
827 input. The @acronym{EOF} comes after any text already sent to it. 828 input. The @acronym{EOF} comes after any text already sent to it.
828 829
829 If @var{process-name} is not supplied, or if it is @code{nil}, then 830 The function returns @var{process}.
830 this function sends the @acronym{EOF} to the current buffer's process. An
831 error is signaled if the current buffer has no process.
832
833 The function returns @var{process-name}.
834 831
835 @smallexample 832 @smallexample
836 @group 833 @group
837 (process-send-eof "shell") 834 (process-send-eof "shell")
838 @result{} "shell" 835 @result{} "shell"
873 user hung up the phone.) 870 user hung up the phone.)
874 871
875 Each of the signal-sending functions takes two optional arguments: 872 Each of the signal-sending functions takes two optional arguments:
876 @var{process-name} and @var{current-group}. 873 @var{process-name} and @var{current-group}.
877 874
878 The argument @var{process-name} must be either a process, the name of 875 The argument @var{process} must be either a process, a process
879 one, or @code{nil}. If it is @code{nil}, the process defaults to the 876 name, a buffer, a buffer name, or @code{nil}. A buffer or buffer name
880 process associated with the current buffer. An error is signaled if 877 stands for a process through @code{get-buffer-process}. @code{nil}
881 @var{process-name} does not identify a process. 878 stands for the process associated with the current buffer. An error
879 is signaled if @var{process} does not identify a process.
882 880
883 The argument @var{current-group} is a flag that makes a difference 881 The argument @var{current-group} is a flag that makes a difference
884 when you are running a job-control shell as an Emacs subprocess. If it 882 when you are running a job-control shell as an Emacs subprocess. If it
885 is non-@code{nil}, then the signal is sent to the current process-group 883 is non-@code{nil}, then the signal is sent to the current process-group
886 of the terminal that Emacs uses to communicate with the subprocess. If 884 of the terminal that Emacs uses to communicate with the subprocess. If
893 communicate with the subprocess, because the operating system does not 891 communicate with the subprocess, because the operating system does not
894 support the distinction in the case of pipes. For the same reason, 892 support the distinction in the case of pipes. For the same reason,
895 job-control shells won't work when a pipe is used. See 893 job-control shells won't work when a pipe is used. See
896 @code{process-connection-type} in @ref{Asynchronous Processes}. 894 @code{process-connection-type} in @ref{Asynchronous Processes}.
897 895
898 @defun interrupt-process &optional process-name current-group 896 @defun interrupt-process &optional process current-group
899 This function interrupts the process @var{process-name} by sending the 897 This function interrupts the process @var{process} by sending the
900 signal @code{SIGINT}. Outside of Emacs, typing the ``interrupt 898 signal @code{SIGINT}. Outside of Emacs, typing the ``interrupt
901 character'' (normally @kbd{C-c} on some systems, and @code{DEL} on 899 character'' (normally @kbd{C-c} on some systems, and @code{DEL} on
902 others) sends this signal. When the argument @var{current-group} is 900 others) sends this signal. When the argument @var{current-group} is
903 non-@code{nil}, you can think of this function as ``typing @kbd{C-c}'' 901 non-@code{nil}, you can think of this function as ``typing @kbd{C-c}''
904 on the terminal by which Emacs talks to the subprocess. 902 on the terminal by which Emacs talks to the subprocess.
905 @end defun 903 @end defun
906 904
907 @defun kill-process &optional process-name current-group 905 @defun kill-process &optional process current-group
908 This function kills the process @var{process-name} by sending the 906 This function kills the process @var{process} by sending the
909 signal @code{SIGKILL}. This signal kills the subprocess immediately, 907 signal @code{SIGKILL}. This signal kills the subprocess immediately,
910 and cannot be handled by the subprocess. 908 and cannot be handled by the subprocess.
911 @end defun 909 @end defun
912 910
913 @defun quit-process &optional process-name current-group 911 @defun quit-process &optional process current-group
914 This function sends the signal @code{SIGQUIT} to the process 912 This function sends the signal @code{SIGQUIT} to the process
915 @var{process-name}. This signal is the one sent by the ``quit 913 @var{process}. This signal is the one sent by the ``quit
916 character'' (usually @kbd{C-b} or @kbd{C-\}) when you are not inside 914 character'' (usually @kbd{C-b} or @kbd{C-\}) when you are not inside
917 Emacs. 915 Emacs.
918 @end defun 916 @end defun
919 917
920 @defun stop-process &optional process-name current-group 918 @defun stop-process &optional process current-group
921 This function stops the process @var{process-name} by sending the 919 This function stops the process @var{process} by sending the
922 signal @code{SIGTSTP}. Use @code{continue-process} to resume its 920 signal @code{SIGTSTP}. Use @code{continue-process} to resume its
923 execution. 921 execution.
924 922
925 Outside of Emacs, on systems with job control, the ``stop character'' 923 Outside of Emacs, on systems with job control, the ``stop character''
926 (usually @kbd{C-z}) normally sends this signal. When 924 (usually @kbd{C-z}) normally sends this signal. When
927 @var{current-group} is non-@code{nil}, you can think of this function as 925 @var{current-group} is non-@code{nil}, you can think of this function as
928 ``typing @kbd{C-z}'' on the terminal Emacs uses to communicate with the 926 ``typing @kbd{C-z}'' on the terminal Emacs uses to communicate with the
929 subprocess. 927 subprocess.
930 @end defun 928 @end defun
931 929
932 @defun continue-process &optional process-name current-group 930 @defun continue-process &optional process current-group
933 This function resumes execution of the process @var{process} by sending 931 This function resumes execution of the process @var{process} by sending
934 it the signal @code{SIGCONT}. This presumes that @var{process-name} was 932 it the signal @code{SIGCONT}. This presumes that @var{process} was
935 stopped previously. 933 stopped previously.
936 @end defun 934 @end defun
937 935
938 @c Emacs 19 feature 936 @c Emacs 19 feature
939 @defun signal-process process signal 937 @defun signal-process process signal
940 This function sends a signal to process @var{process}. The argument 938 This function sends a signal to process @var{process}. The argument
941 @var{signal} specifies which signal to send; it should be an integer. 939 @var{signal} specifies which signal to send; it should be an integer.
942 940
943 You can specify the target process by its process @acronym{ID}; that allows 941 The @var{process} argument can be a system process @acronym{ID}; that
944 you to send signals to processes that are not children of Emacs. 942 allows you to send signals to processes that are not children of
943 Emacs.
945 @end defun 944 @end defun
946 945
947 @node Output from Processes 946 @node Output from Processes
948 @section Receiving Output from Processes 947 @section Receiving Output from Processes
949 @cindex process output 948 @cindex process output
1238 1237
1239 When Emacs writes process output directly into a multibyte buffer, 1238 When Emacs writes process output directly into a multibyte buffer,
1240 it decodes the output according to the process output coding system. 1239 it decodes the output according to the process output coding system.
1241 If the coding system is @code{raw-text} or @code{no-conversion}, Emacs 1240 If the coding system is @code{raw-text} or @code{no-conversion}, Emacs
1242 converts the unibyte output to multibyte using 1241 converts the unibyte output to multibyte using
1243 @code{string-to-multibyte}, inserts the resulting multibyte text. 1242 @code{string-to-multibyte}, and inserts the resulting multibyte text.
1244 1243
1245 You can use @code{set-process-coding-system} to specify which coding 1244 You can use @code{set-process-coding-system} to specify which coding
1246 system to use (@pxref{Process Information}). Otherwise, the coding 1245 system to use (@pxref{Process Information}). Otherwise, the coding
1247 system comes from @code{coding-system-for-read}, if that is 1246 system comes from @code{coding-system-for-read}, if that is
1248 non-@code{nil}; or else from the defaulting mechanism (@pxref{Default 1247 non-@code{nil}; or else from the defaulting mechanism (@pxref{Default
1441 1440
1442 @node Query Before Exit 1441 @node Query Before Exit
1443 @section Querying Before Exit 1442 @section Querying Before Exit
1444 1443
1445 When Emacs exits, it terminates all its subprocesses by sending them 1444 When Emacs exits, it terminates all its subprocesses by sending them
1446 the @code{SIGHUP} signal. Because some subprocesses are doing 1445 the @code{SIGHUP} signal. Because subprocesses may be doing
1447 valuable work, Emacs normally asks the user to confirm that it is ok 1446 valuable work, Emacs normally asks the user to confirm that it is ok
1448 to terminate them. Each process has a query flag which, if 1447 to terminate them. Each process has a query flag which, if
1449 non-@code{nil}, says that Emacs should ask for confirmation before 1448 non-@code{nil}, says that Emacs should ask for confirmation before
1450 exiting and thus killing that process. The default for the query flag 1449 exiting and thus killing that process. The default for the query flag
1451 is @code{t}, meaning @emph{do} query. 1450 is @code{t}, meaning @emph{do} query.