Mercurial > hg > xemacs-beta
comparison src/callproc.c @ 20:859a2309aef8 r19-15b93
Import from CVS: tag r19-15b93
author | cvs |
---|---|
date | Mon, 13 Aug 2007 08:50:05 +0200 |
parents | 9ee227acff29 |
children | e04119814345 |
comparison
equal
deleted
inserted
replaced
19:ac1f612d5250 | 20:859a2309aef8 |
---|---|
149 /* terminate this branch of the fork, without closing stdin/out/etc. */ | 149 /* terminate this branch of the fork, without closing stdin/out/etc. */ |
150 _exit (1); | 150 _exit (1); |
151 } | 151 } |
152 #endif /* unused */ | 152 #endif /* unused */ |
153 | 153 |
154 DEFUN ("call-process-internal", Fcall_process_internal, | 154 DEFUN ("call-process-internal", Fcall_process_internal, 1, MANY, 0, /* |
155 Scall_process_internal, 1, MANY, 0 /* | |
156 Call PROGRAM synchronously in separate process, with coding-system specified. | 155 Call PROGRAM synchronously in separate process, with coding-system specified. |
157 Arguments are | 156 Arguments are |
158 (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS). | 157 (PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS). |
159 The program's input comes from file INFILE (nil means `/dev/null'). | 158 The program's input comes from file INFILE (nil means `/dev/null'). |
160 Insert output in BUFFER before point; t means current buffer; | 159 Insert output in BUFFER before point; t means current buffer; |
171 If BUFFER is 0, `call-process' returns immediately with value nil. | 170 If BUFFER is 0, `call-process' returns immediately with value nil. |
172 Otherwise it waits for PROGRAM to terminate and returns a numeric exit status | 171 Otherwise it waits for PROGRAM to terminate and returns a numeric exit status |
173 or a signal description string. | 172 or a signal description string. |
174 If you quit, the process is killed with SIGINT, or SIGKILL if you | 173 If you quit, the process is killed with SIGINT, or SIGKILL if you |
175 quit again. | 174 quit again. |
176 */ ) | 175 */ |
177 (nargs, args) | 176 (int nargs, Lisp_Object *args)) |
178 int nargs; | |
179 Lisp_Object *args; | |
180 { | 177 { |
181 /* This function can GC */ | 178 /* This function can GC */ |
182 Lisp_Object infile, buffer, current_dir, display, path; | 179 Lisp_Object infile, buffer, current_dir, display, path; |
183 int fd[2]; | 180 int fd[2]; |
184 int filefd; | 181 int filefd; |
292 for (i = 4; i < nargs; i++) | 289 for (i = 4; i < nargs; i++) |
293 { | 290 { |
294 CHECK_STRING (args[i]); | 291 CHECK_STRING (args[i]); |
295 new_argv[i - 3] = (char *) XSTRING_DATA (args[i]); | 292 new_argv[i - 3] = (char *) XSTRING_DATA (args[i]); |
296 } | 293 } |
297 /* Program name is first command arg */ | 294 new_argv[nargs - 3] = 0; |
298 new_argv[0] = (char *) XSTRING_DATA (args[0]); | |
299 new_argv[i - 3] = 0; | |
300 } | 295 } |
301 | 296 |
297 if (NILP (path)) | |
298 report_file_error ("Searching for program", Fcons (args[0], Qnil)); | |
299 new_argv[0] = (char *) XSTRING_DATA (path); | |
300 | |
302 filefd = open ((char *) XSTRING_DATA (infile), O_RDONLY, 0); | 301 filefd = open ((char *) XSTRING_DATA (infile), O_RDONLY, 0); |
303 if (filefd < 0) | 302 if (filefd < 0) |
304 { | 303 report_file_error ("Opening process input file", Fcons (infile, Qnil)); |
305 report_file_error ("Opening process input file", | 304 |
306 Fcons (infile, Qnil)); | |
307 } | |
308 | |
309 if (NILP (path)) | |
310 { | |
311 close (filefd); | |
312 report_file_error ("Searching for program", | |
313 Fcons (args[0], Qnil)); | |
314 } | |
315 new_argv[0] = (char *) XSTRING_DATA (path); | |
316 | |
317 #ifdef MSDOS | 305 #ifdef MSDOS |
318 /* These vars record information from process termination. | 306 /* These vars record information from process termination. |
319 Clear them now before process can possibly terminate, | 307 Clear them now before process can possibly terminate, |
320 to avoid timing error if process terminates soon. */ | 308 to avoid timing error if process terminates soon. */ |
321 synch_process_death = 0; | 309 synch_process_death = 0; |
662 #endif | 650 #endif |
663 | 651 |
664 #if !defined (NO_SUBPROCESSES) | 652 #if !defined (NO_SUBPROCESSES) |
665 /* Close Emacs's descriptors that this process should not have. */ | 653 /* Close Emacs's descriptors that this process should not have. */ |
666 close_process_descs (); | 654 close_process_descs (); |
667 #endif | 655 #endif /* not NO_SUBPROCESSES */ |
668 close_load_descs (); | 656 close_load_descs (); |
669 | 657 |
670 /* Note that use of alloca is always safe here. It's obvious for systems | 658 /* Note that use of alloca is always safe here. It's obvious for systems |
671 that do not have true vfork or that have true (stack) alloca. | 659 that do not have true vfork or that have true (stack) alloca. |
672 If using vfork and C_ALLOCA it is safe because that changes | 660 If using vfork and C_ALLOCA it is safe because that changes |
889 } | 877 } |
890 | 878 |
891 return 0; | 879 return 0; |
892 } | 880 } |
893 | 881 |
894 DEFUN ("getenv", Fgetenv, Sgetenv, 1, 2, "sEnvironment variable: \np" /* | 882 DEFUN ("getenv", Fgetenv, 1, 2, "sEnvironment variable: \np", /* |
895 Return the value of environment variable VAR, as a string. | 883 Return the value of environment variable VAR, as a string. |
896 VAR is a string, the name of the variable. | 884 VAR is a string, the name of the variable. |
897 When invoked interactively, prints the value in the echo area. | 885 When invoked interactively, prints the value in the echo area. |
898 */ ) | 886 */ |
899 (var, interactivep) | 887 (var, interactivep)) |
900 Lisp_Object var, interactivep; | |
901 { | 888 { |
902 Bufbyte *value; | 889 Bufbyte *value; |
903 Bytecount valuelen; | 890 Bytecount valuelen; |
904 Lisp_Object v = Qnil; | 891 Lisp_Object v = Qnil; |
905 struct gcpro gcpro1; | 892 struct gcpro gcpro1; |
1090 | 1077 |
1091 void | 1078 void |
1092 syms_of_callproc (void) | 1079 syms_of_callproc (void) |
1093 { | 1080 { |
1094 #ifndef VMS | 1081 #ifndef VMS |
1095 defsubr (&Scall_process_internal); | 1082 DEFSUBR (Fcall_process_internal); |
1096 defsubr (&Sgetenv); | 1083 DEFSUBR (Fgetenv); |
1097 #endif | 1084 #endif |
1098 } | 1085 } |
1099 | 1086 |
1100 void | 1087 void |
1101 vars_of_callproc (void) | 1088 vars_of_callproc (void) |