Add missing file... don't ask.

This commit is contained in:
Sebastian Lackner 2015-02-28 02:01:53 +01:00
parent ec8049fcf5
commit 96bb4ddd1d

View File

@ -0,0 +1,67 @@
From 28fdcfb34cac0aee803caa5bb8cb687be197c7d8 Mon Sep 17 00:00:00 2001
From: Andrew Cook <ariscop@gmail.com>
Date: Thu, 26 Feb 2015 13:10:41 +1100
Subject: server: Implement JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE.
---
dlls/kernel32/tests/process.c | 1 -
server/process.c | 17 ++++++++++++++++-
2 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/dlls/kernel32/tests/process.c b/dlls/kernel32/tests/process.c
index ec79418..3c7d9f6 100644
--- a/dlls/kernel32/tests/process.c
+++ b/dlls/kernel32/tests/process.c
@@ -2443,7 +2443,6 @@ static void test_KillOnJobClose(void)
CloseHandle(job);
dwret = WaitForSingleObject(pi.hProcess, 500);
- todo_wine
ok(dwret == WAIT_OBJECT_0, "WaitForSingleObject returned %u\n", dwret);
if (dwret == WAIT_TIMEOUT) TerminateProcess(pi.hProcess, 0);
diff --git a/server/process.c b/server/process.c
index 73fe08a..28f872d 100644
--- a/server/process.c
+++ b/server/process.c
@@ -141,6 +141,7 @@ static void job_dump( struct object *obj, int verbose );
static struct object_type *job_get_type( struct object *obj );
static int job_signaled( struct object *obj, struct wait_queue_entry *entry );
static unsigned int job_map_access( struct object *obj, unsigned int access );
+static int job_close_handle( struct object *, struct process *process, obj_handle_t handle );
static void job_destroy( struct object *obj );
struct job
@@ -170,7 +171,7 @@ static const struct object_ops job_ops =
default_set_sd, /* set_sd */
no_lookup_name, /* lookup_name */
no_open_file, /* open_file */
- no_close_handle, /* close_handle */
+ job_close_handle, /* close_handle */
job_destroy /* destroy */
};
@@ -286,6 +287,20 @@ static void terminate_job( struct job *job, int exit_code )
job->terminating = 0;
}
+static int job_close_handle( struct object *obj, struct process *process, obj_handle_t handle )
+{
+ struct job *job = (struct job *)obj;
+ assert( obj->ops == &job_ops );
+
+ /* If this is the last handle and JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE is set,
+ * then terminate all associcated processes. We can't use the refcount because
+ * processes have a reference to the job object. */
+ if (obj->handlecount == 1 && (job->limit_flags & JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE))
+ terminate_job( job, 0 );
+
+ return 1;
+}
+
static void job_destroy( struct object *obj )
{
struct job *job = (struct job *)obj;
--
2.3.0