diff options
| author | Eli Zaretskii | 2013-11-16 17:50:56 +0200 |
|---|---|---|
| committer | Eli Zaretskii | 2013-11-16 17:50:56 +0200 |
| commit | 8dc689ce3897b6a11877ecf9140fec859f1b95a5 (patch) | |
| tree | 7a1c83c9a18720f7761e2e4fbd2f4dc8be75e9e0 /src | |
| parent | f5c287f4fa22070b4b65fc6e731dd359daa7acce (diff) | |
| download | emacs-8dc689ce3897b6a11877ecf9140fec859f1b95a5.tar.gz emacs-8dc689ce3897b6a11877ecf9140fec859f1b95a5.zip | |
Converted sys_unlink and sys_rmdir, got rid of pending deletion in w32proc.c.
Diffstat (limited to 'src')
| -rw-r--r-- | src/w32.c | 37 | ||||
| -rw-r--r-- | src/w32.h | 8 | ||||
| -rw-r--r-- | src/w32proc.c | 56 |
3 files changed, 33 insertions, 68 deletions
| @@ -4011,7 +4011,22 @@ sys_rename (char const *old, char const *new) | |||
| 4011 | int | 4011 | int |
| 4012 | sys_rmdir (const char * path) | 4012 | sys_rmdir (const char * path) |
| 4013 | { | 4013 | { |
| 4014 | return _rmdir (map_w32_filename (path, NULL)); | 4014 | path = map_w32_filename (path, NULL); |
| 4015 | |||
| 4016 | if (w32_unicode_filenames) | ||
| 4017 | { | ||
| 4018 | wchar_t path_w[MAX_PATH]; | ||
| 4019 | |||
| 4020 | filename_to_utf16 (path, path_w); | ||
| 4021 | return _wrmdir (path_w); | ||
| 4022 | } | ||
| 4023 | else | ||
| 4024 | { | ||
| 4025 | char path_a[MAX_PATH]; | ||
| 4026 | |||
| 4027 | filename_to_ansi (path, path_a); | ||
| 4028 | return _rmdir (path_a); | ||
| 4029 | } | ||
| 4015 | } | 4030 | } |
| 4016 | 4031 | ||
| 4017 | int | 4032 | int |
| @@ -4019,9 +4034,23 @@ sys_unlink (const char * path) | |||
| 4019 | { | 4034 | { |
| 4020 | path = map_w32_filename (path, NULL); | 4035 | path = map_w32_filename (path, NULL); |
| 4021 | 4036 | ||
| 4022 | /* On Unix, unlink works without write permission. */ | 4037 | if (w32_unicode_filenames) |
| 4023 | _chmod (path, 0666); | 4038 | { |
| 4024 | return _unlink (path); | 4039 | wchar_t path_w[MAX_PATH]; |
| 4040 | |||
| 4041 | filename_to_utf16 (path, path_w); | ||
| 4042 | /* On Unix, unlink works without write permission. */ | ||
| 4043 | _wchmod (path_w, 0666); | ||
| 4044 | return _wunlink (path_w); | ||
| 4045 | } | ||
| 4046 | else | ||
| 4047 | { | ||
| 4048 | char path_a[MAX_PATH]; | ||
| 4049 | |||
| 4050 | filename_to_ansi (path, path_a); | ||
| 4051 | _chmod (path_a, 0666); | ||
| 4052 | return _unlink (path_a); | ||
| 4053 | } | ||
| 4025 | } | 4054 | } |
| 4026 | 4055 | ||
| 4027 | static FILETIME utc_base_ft; | 4056 | static FILETIME utc_base_ft; |
| @@ -103,12 +103,6 @@ typedef struct _child_process | |||
| 103 | OVERLAPPED ovl_read; | 103 | OVERLAPPED ovl_read; |
| 104 | /* Used for async write operations on serial comm ports. */ | 104 | /* Used for async write operations on serial comm ports. */ |
| 105 | OVERLAPPED ovl_write; | 105 | OVERLAPPED ovl_write; |
| 106 | /* Input file, if any, for this subprocess. Should only be non-NULL | ||
| 107 | for async subprocesses. */ | ||
| 108 | char *input_file; | ||
| 109 | /* If non-zero, the subprocess input file is temporary and should be | ||
| 110 | deleted when the subprocess exits. */ | ||
| 111 | int pending_deletion; | ||
| 112 | } child_process; | 106 | } child_process; |
| 113 | 107 | ||
| 114 | #define MAXDESC FD_SETSIZE | 108 | #define MAXDESC FD_SETSIZE |
| @@ -199,8 +193,6 @@ extern int pipe2 (int *, int); | |||
| 199 | extern void set_process_dir (char *); | 193 | extern void set_process_dir (char *); |
| 200 | extern int sys_spawnve (int, char *, char **, char **); | 194 | extern int sys_spawnve (int, char *, char **, char **); |
| 201 | extern void register_child (pid_t, int); | 195 | extern void register_child (pid_t, int); |
| 202 | extern void record_infile (pid_t, char *); | ||
| 203 | extern void record_pending_deletion (char *); | ||
| 204 | 196 | ||
| 205 | extern void sys_sleep (int); | 197 | extern void sys_sleep (int); |
| 206 | extern int sys_link (const char *, const char *); | 198 | extern int sys_link (const char *, const char *); |
diff --git a/src/w32proc.c b/src/w32proc.c index 89748267bc6..de4e9103173 100644 --- a/src/w32proc.c +++ b/src/w32proc.c | |||
| @@ -861,8 +861,6 @@ new_child (void) | |||
| 861 | cp->pid = -1; | 861 | cp->pid = -1; |
| 862 | cp->procinfo.hProcess = NULL; | 862 | cp->procinfo.hProcess = NULL; |
| 863 | cp->status = STATUS_READ_ERROR; | 863 | cp->status = STATUS_READ_ERROR; |
| 864 | cp->input_file = NULL; | ||
| 865 | cp->pending_deletion = 0; | ||
| 866 | 864 | ||
| 867 | /* use manual reset event so that select() will function properly */ | 865 | /* use manual reset event so that select() will function properly */ |
| 868 | cp->char_avail = CreateEvent (NULL, TRUE, FALSE, NULL); | 866 | cp->char_avail = CreateEvent (NULL, TRUE, FALSE, NULL); |
| @@ -911,21 +909,6 @@ delete_child (child_process *cp) | |||
| 911 | if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL) | 909 | if (!CHILD_ACTIVE (cp) && cp->procinfo.hProcess == NULL) |
| 912 | return; | 910 | return; |
| 913 | 911 | ||
| 914 | /* Delete the child's temporary input file, if any, that is pending | ||
| 915 | deletion. */ | ||
| 916 | if (cp->input_file) | ||
| 917 | { | ||
| 918 | if (cp->pending_deletion) | ||
| 919 | { | ||
| 920 | if (unlink (cp->input_file)) | ||
| 921 | DebPrint (("delete_child.unlink (%s) failed, errno: %d\n", | ||
| 922 | cp->input_file, errno)); | ||
| 923 | cp->pending_deletion = 0; | ||
| 924 | } | ||
| 925 | xfree (cp->input_file); | ||
| 926 | cp->input_file = NULL; | ||
| 927 | } | ||
| 928 | |||
| 929 | /* reap thread if necessary */ | 912 | /* reap thread if necessary */ |
| 930 | if (cp->thrd) | 913 | if (cp->thrd) |
| 931 | { | 914 | { |
| @@ -1182,45 +1165,6 @@ register_child (pid_t pid, int fd) | |||
| 1182 | fd_info[fd].cp = cp; | 1165 | fd_info[fd].cp = cp; |
| 1183 | } | 1166 | } |
| 1184 | 1167 | ||
| 1185 | /* Record INFILE as an input file for process PID. */ | ||
| 1186 | void | ||
| 1187 | record_infile (pid_t pid, char *infile) | ||
| 1188 | { | ||
| 1189 | child_process *cp; | ||
| 1190 | |||
| 1191 | /* INFILE should never be NULL, since xstrdup would have signaled | ||
| 1192 | memory full condition in that case, see callproc.c where this | ||
| 1193 | function is called. */ | ||
| 1194 | eassert (infile); | ||
| 1195 | |||
| 1196 | cp = find_child_pid ((DWORD)pid); | ||
| 1197 | if (cp == NULL) | ||
| 1198 | { | ||
| 1199 | DebPrint (("record_infile is unable to find pid %lu\n", pid)); | ||
| 1200 | return; | ||
| 1201 | } | ||
| 1202 | |||
| 1203 | cp->input_file = infile; | ||
| 1204 | } | ||
| 1205 | |||
| 1206 | /* Mark the input file INFILE of the corresponding subprocess as | ||
| 1207 | temporary, to be deleted when the subprocess exits. */ | ||
| 1208 | void | ||
| 1209 | record_pending_deletion (char *infile) | ||
| 1210 | { | ||
| 1211 | child_process *cp; | ||
| 1212 | |||
| 1213 | eassert (infile); | ||
| 1214 | |||
| 1215 | for (cp = child_procs + (child_proc_count-1); cp >= child_procs; cp--) | ||
| 1216 | if (CHILD_ACTIVE (cp) | ||
| 1217 | && cp->input_file && xstrcasecmp (cp->input_file, infile) == 0) | ||
| 1218 | { | ||
| 1219 | cp->pending_deletion = 1; | ||
| 1220 | break; | ||
| 1221 | } | ||
| 1222 | } | ||
| 1223 | |||
| 1224 | /* Called from waitpid when a process exits. */ | 1168 | /* Called from waitpid when a process exits. */ |
| 1225 | static void | 1169 | static void |
| 1226 | reap_subprocess (child_process *cp) | 1170 | reap_subprocess (child_process *cp) |