Mercurial > emacs
comparison src/callproc.c @ 21694:6e12eeda6913
(Fcall_process) [MSDOS]: Call child_setup instead of run_msdos_command.
(child_setup) [MSDOS]: Call run_msdos_command here.
(child_setup) [DOS_NT]: Get past drive letter in pwd. Don't call
close_load_descs, since we are not in a vfork.
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Tue, 21 Apr 1998 11:14:24 +0000 |
parents | ad899130056e |
children | 5f8f1b124f45 |
comparison
equal
deleted
inserted
replaced
21693:fc0153e88b71 | 21694:6e12eeda6913 |
---|---|
520 } | 520 } |
521 | 521 |
522 current_dir = ENCODE_FILE (current_dir); | 522 current_dir = ENCODE_FILE (current_dir); |
523 | 523 |
524 #ifdef MSDOS /* MW, July 1993 */ | 524 #ifdef MSDOS /* MW, July 1993 */ |
525 /* ??? Someone who knows MSDOG needs to check whether this properly | 525 /* Note that on MSDOS `child_setup' actually returns the child process |
526 closes all descriptors that it opens. | |
527 | |
528 Note that run_msdos_command() actually returns the child process | |
529 exit status, not its PID, so we assign it to `synch_process_retcode' | 526 exit status, not its PID, so we assign it to `synch_process_retcode' |
530 below. */ | 527 below. */ |
531 pid = run_msdos_command (new_argv, current_dir, | 528 pid = child_setup (filefd, outfilefd, fd_error, (char **) new_argv, |
532 filefd, outfilefd, fd_error); | 529 0, current_dir); |
533 | 530 |
534 /* Record that the synchronous process exited and note its | 531 /* Record that the synchronous process exited and note its |
535 termination status. */ | 532 termination status. */ |
536 synch_process_alive = 0; | 533 synch_process_alive = 0; |
537 synch_process_retcode = pid; | 534 synch_process_retcode = pid; |
874 | 871 |
875 This function may change environ for the superior process. | 872 This function may change environ for the superior process. |
876 Therefore, the superior process must save and restore the value | 873 Therefore, the superior process must save and restore the value |
877 of environ around the vfork and the call to this function. | 874 of environ around the vfork and the call to this function. |
878 | 875 |
879 ENV is the environment for the subprocess. | |
880 | |
881 SET_PGRP is nonzero if we should put the subprocess into a separate | 876 SET_PGRP is nonzero if we should put the subprocess into a separate |
882 process group. | 877 process group. |
883 | 878 |
884 CURRENT_DIR is an elisp string giving the path of the current | 879 CURRENT_DIR is an elisp string giving the path of the current |
885 directory the subprocess should have. Since we can't really signal | 880 directory the subprocess should have. Since we can't really signal |
891 int in, out, err; | 886 int in, out, err; |
892 register char **new_argv; | 887 register char **new_argv; |
893 int set_pgrp; | 888 int set_pgrp; |
894 Lisp_Object current_dir; | 889 Lisp_Object current_dir; |
895 { | 890 { |
896 #ifdef MSDOS | |
897 /* The MSDOS port of gcc cannot fork, vfork, ... so we must call system | |
898 instead. */ | |
899 #else /* not MSDOS */ | |
900 char **env; | 891 char **env; |
901 char *pwd_var; | 892 char *pwd_var; |
902 #ifdef WINDOWSNT | 893 #ifdef WINDOWSNT |
903 int cpid; | 894 int cpid; |
904 HANDLE handles[3]; | 895 HANDLE handles[3]; |
917 | 908 |
918 #ifdef subprocesses | 909 #ifdef subprocesses |
919 /* Close Emacs's descriptors that this process should not have. */ | 910 /* Close Emacs's descriptors that this process should not have. */ |
920 close_process_descs (); | 911 close_process_descs (); |
921 #endif | 912 #endif |
913 /* DOS_NT isn't in a vfork, so if we are in the middle of load-file, | |
914 we will lose if we call close_load_descs here. */ | |
915 #ifndef DOS_NT | |
922 close_load_descs (); | 916 close_load_descs (); |
917 #endif | |
923 | 918 |
924 /* Note that use of alloca is always safe here. It's obvious for systems | 919 /* Note that use of alloca is always safe here. It's obvious for systems |
925 that do not have true vfork or that have true (stack) alloca. | 920 that do not have true vfork or that have true (stack) alloca. |
926 If using vfork and C_ALLOCA it is safe because that changes | 921 If using vfork and C_ALLOCA it is safe because that changes |
927 the superior's static variables as if the superior had done alloca | 922 the superior's static variables as if the superior had done alloca |
936 bcopy ("PWD=", pwd_var, 4); | 931 bcopy ("PWD=", pwd_var, 4); |
937 bcopy (XSTRING (current_dir)->data, temp, i); | 932 bcopy (XSTRING (current_dir)->data, temp, i); |
938 if (!IS_DIRECTORY_SEP (temp[i - 1])) temp[i++] = DIRECTORY_SEP; | 933 if (!IS_DIRECTORY_SEP (temp[i - 1])) temp[i++] = DIRECTORY_SEP; |
939 temp[i] = 0; | 934 temp[i] = 0; |
940 | 935 |
941 #ifndef WINDOWSNT | 936 #ifndef DOS_NT |
942 /* We can't signal an Elisp error here; we're in a vfork. Since | 937 /* We can't signal an Elisp error here; we're in a vfork. Since |
943 the callers check the current directory before forking, this | 938 the callers check the current directory before forking, this |
944 should only return an error if the directory's permissions | 939 should only return an error if the directory's permissions |
945 are changed between the check and this chdir, but we should | 940 are changed between the check and this chdir, but we should |
946 at least check. */ | 941 at least check. */ |
947 if (chdir (temp) < 0) | 942 if (chdir (temp) < 0) |
948 _exit (errno); | 943 _exit (errno); |
944 #endif | |
945 | |
946 #ifdef DOS_NT | |
947 /* Get past the drive letter, so that d:/ is left alone. */ | |
948 if (i > 2 && IS_DEVICE_SEP (temp[1]) && IS_DIRECTORY_SEP (temp[2])) | |
949 { | |
950 temp += 2; | |
951 i -= 2; | |
952 } | |
949 #endif | 953 #endif |
950 | 954 |
951 /* Strip trailing slashes for PWD, but leave "/" and "//" alone. */ | 955 /* Strip trailing slashes for PWD, but leave "/" and "//" alone. */ |
952 while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1])) | 956 while (i > 2 && IS_DIRECTORY_SEP (temp[i - 1])) |
953 temp[--i] = 0; | 957 temp[--i] = 0; |
1030 err = out; | 1034 err = out; |
1031 else | 1035 else |
1032 err = relocate_fd (err, 3); | 1036 err = relocate_fd (err, 3); |
1033 } | 1037 } |
1034 | 1038 |
1039 #ifndef MSDOS | |
1035 close (0); | 1040 close (0); |
1036 close (1); | 1041 close (1); |
1037 close (2); | 1042 close (2); |
1038 | 1043 |
1039 dup2 (in, 0); | 1044 dup2 (in, 0); |
1040 dup2 (out, 1); | 1045 dup2 (out, 1); |
1041 dup2 (err, 2); | 1046 dup2 (err, 2); |
1042 close (in); | 1047 close (in); |
1043 close (out); | 1048 close (out); |
1044 close (err); | 1049 close (err); |
1050 #endif /* not MSDOS */ | |
1045 #endif /* not WINDOWSNT */ | 1051 #endif /* not WINDOWSNT */ |
1046 | 1052 |
1047 #if defined(USG) && !defined(BSD_PGRPS) | 1053 #if defined(USG) && !defined(BSD_PGRPS) |
1048 #ifndef SETPGRP_RELEASES_CTTY | 1054 #ifndef SETPGRP_RELEASES_CTTY |
1049 setpgrp (); /* No arguments but equivalent in this case */ | 1055 setpgrp (); /* No arguments but equivalent in this case */ |
1056 | 1062 |
1057 #ifdef vipc | 1063 #ifdef vipc |
1058 something missing here; | 1064 something missing here; |
1059 #endif /* vipc */ | 1065 #endif /* vipc */ |
1060 | 1066 |
1067 #ifdef MSDOS | |
1068 pid = run_msdos_command (new_argv, pwd_var + 4, in, out, err, env); | |
1069 if (pid == -1) | |
1070 /* An error occurred while trying to run the subprocess. */ | |
1071 report_file_error ("Spawning child process", Qnil); | |
1072 return pid; | |
1073 #else /* not MSDOS */ | |
1061 #ifdef WINDOWSNT | 1074 #ifdef WINDOWSNT |
1062 /* Spawn the child. (See ntproc.c:Spawnve). */ | 1075 /* Spawn the child. (See ntproc.c:Spawnve). */ |
1063 cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env); | 1076 cpid = spawnve (_P_NOWAIT, new_argv[0], new_argv, env); |
1064 reset_standard_handles (in, out, err, handles); | 1077 reset_standard_handles (in, out, err, handles); |
1065 if (cpid == -1) | 1078 if (cpid == -1) |