* xterm.h (struct x_output): Remove toolbar_detached member since it's
[bpt/emacs.git] / src / w32.c
index aa3431a..9ebc970 100644 (file)
--- a/src/w32.c
+++ b/src/w32.c
@@ -4876,8 +4876,31 @@ acl_set_file (const char *fname, acl_type_t type, acl_t acl)
       retval = 0;
       errno = e;
     }
-  else if (err == ERROR_INVALID_OWNER)
-    errno = EPERM;
+  else if (err == ERROR_INVALID_OWNER || err == ERROR_NOT_ALL_ASSIGNED)
+    {
+      /* Maybe the requested ACL and the one the file already has are
+        identical, in which case we can silently ignore the
+        failure.  (And no, Windows doesn't.)  */
+      acl_t current_acl = acl_get_file (fname, ACL_TYPE_ACCESS);
+
+      errno = EPERM;
+      if (current_acl)
+       {
+         char *acl_from = acl_to_text (current_acl, NULL);
+         char *acl_to = acl_to_text (acl, NULL);
+
+         if (acl_from && acl_to && xstrcasecmp (acl_from, acl_to) == 0)
+           {
+             retval = 0;
+             errno = e;
+           }
+         if (acl_from)
+           acl_free (acl_from);
+         if (acl_to)
+           acl_free (acl_to);
+         acl_free (current_acl);
+       }
+    }
   else if (err == ERROR_FILE_NOT_FOUND || err == ERROR_PATH_NOT_FOUND)
     errno = ENOENT;
 
@@ -6401,7 +6424,21 @@ sys_close (int fd)
 
                  winsock_inuse--; /* count open sockets */
                }
-             delete_child (cp);
+             /* If the process handle is NULL, it's either a socket
+                or serial connection, or a subprocess that was
+                already reaped by reap_subprocess, but whose
+                resources were not yet freed, because its output was
+                not fully read yet by the time it was reaped.  (This
+                usually happens with async subprocesses whose output
+                is being read by Emacs.)  Otherwise, this process was
+                not reaped yet, so we set its FD to a negative value
+                to make sure sys_select will eventually get to
+                calling the SIGCHLD handler for it, which will then
+                invoke waitpid and reap_subprocess.  */
+             if (cp->procinfo.hProcess == NULL)
+               delete_child (cp);
+             else
+               cp->fd = -1;
            }
        }
     }