mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[WINSRV] usersrv: Don't terminate processes with no top level windows
Consrv will handle these.
This commit is contained in:
parent
cc710885d0
commit
8ebff93b35
1 changed files with 33 additions and 15 deletions
|
@ -397,7 +397,7 @@ IsConsoleMode(VOID)
|
||||||
/************************************************/
|
/************************************************/
|
||||||
|
|
||||||
|
|
||||||
static VOID
|
static BOOL
|
||||||
ThreadShutdownNotify(IN PCSR_THREAD CsrThread,
|
ThreadShutdownNotify(IN PCSR_THREAD CsrThread,
|
||||||
IN ULONG Flags,
|
IN ULONG Flags,
|
||||||
IN ULONG Flags2,
|
IN ULONG Flags2,
|
||||||
|
@ -425,7 +425,7 @@ ThreadShutdownNotify(IN PCSR_THREAD CsrThread,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
Context->wParam = Flags2;
|
Context->wParam = Flags2;
|
||||||
|
@ -480,22 +480,25 @@ ThreadShutdownNotify(IN PCSR_THREAD CsrThread,
|
||||||
SwitchDesktop(Context->OldDesktop);
|
SwitchDesktop(Context->OldDesktop);
|
||||||
MY_DPRINT("Switched back ok\n");
|
MY_DPRINT("Switched back ok\n");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL
|
static ULONG
|
||||||
NotifyProcessForShutdown(PCSR_PROCESS CsrProcess,
|
NotifyUserProcessForShutdown(PCSR_PROCESS CsrProcess,
|
||||||
PSHUTDOWN_SETTINGS ShutdownSettings,
|
PSHUTDOWN_SETTINGS ShutdownSettings,
|
||||||
UINT Flags)
|
UINT Flags)
|
||||||
{
|
{
|
||||||
DWORD QueryResult = QUERY_RESULT_CONTINUE;
|
DWORD QueryResult = QUERY_RESULT_CONTINUE;
|
||||||
PCSR_PROCESS Process;
|
PCSR_PROCESS Process;
|
||||||
PCSR_THREAD Thread;
|
PCSR_THREAD Thread;
|
||||||
PLIST_ENTRY NextEntry;
|
PLIST_ENTRY NextEntry;
|
||||||
NOTIFY_CONTEXT Context;
|
NOTIFY_CONTEXT Context;
|
||||||
|
BOOL FoundWindows = FALSE;
|
||||||
|
|
||||||
/* In case we make a forced shutdown, just kill the process */
|
/* In case we make a forced shutdown, just kill the process */
|
||||||
if (Flags & EWX_FORCE)
|
if (Flags & EWX_FORCE)
|
||||||
return TRUE;
|
return CsrShutdownCsrProcess;
|
||||||
|
|
||||||
Context.ShutdownSettings = ShutdownSettings;
|
Context.ShutdownSettings = ShutdownSettings;
|
||||||
Context.QueryResult = QUERY_RESULT_CONTINUE; // We continue shutdown by default.
|
Context.QueryResult = QUERY_RESULT_CONTINUE; // We continue shutdown by default.
|
||||||
|
@ -523,9 +526,10 @@ NotifyProcessForShutdown(PCSR_PROCESS CsrProcess,
|
||||||
CsrUnlockProcess(Process);
|
CsrUnlockProcess(Process);
|
||||||
|
|
||||||
Context.QueryResult = QUERY_RESULT_CONTINUE;
|
Context.QueryResult = QUERY_RESULT_CONTINUE;
|
||||||
ThreadShutdownNotify(Thread, Flags,
|
if (ThreadShutdownNotify(Thread, Flags, MCS_QUERYENDSESSION, &Context))
|
||||||
MCS_QUERYENDSESSION,
|
{
|
||||||
&Context);
|
FoundWindows = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
/* Lock the process again and dereference the thread */
|
/* Lock the process again and dereference the thread */
|
||||||
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
CsrLockProcessByClientId(CsrProcess->ClientId.UniqueProcess, &Process);
|
||||||
|
@ -535,6 +539,14 @@ NotifyProcessForShutdown(PCSR_PROCESS CsrProcess,
|
||||||
/**/if (Context.QueryResult == QUERY_RESULT_ABORT) goto Quit;/**/
|
/**/if (Context.QueryResult == QUERY_RESULT_ABORT) goto Quit;/**/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!FoundWindows)
|
||||||
|
{
|
||||||
|
/* We looped all threads but no top level window was found so we didn't send any message */
|
||||||
|
/* Let the console server run the generic process shutdown handler */
|
||||||
|
CsrUnlockProcess(Process);
|
||||||
|
return CsrShutdownNonCsrProcess;
|
||||||
|
}
|
||||||
|
|
||||||
QueryResult = Context.QueryResult;
|
QueryResult = Context.QueryResult;
|
||||||
MY_DPRINT2("QueryResult = %s\n",
|
MY_DPRINT2("QueryResult = %s\n",
|
||||||
QueryResult == QUERY_RESULT_ABORT ? "Abort" : "Continue");
|
QueryResult == QUERY_RESULT_ABORT ? "Abort" : "Continue");
|
||||||
|
@ -588,7 +600,10 @@ Quit:
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Kill the process unless we abort shutdown */
|
/* Kill the process unless we abort shutdown */
|
||||||
return (QueryResult != QUERY_RESULT_ABORT);
|
if (QueryResult == QUERY_RESULT_ABORT)
|
||||||
|
return CsrShutdownCancelled;
|
||||||
|
|
||||||
|
return CsrShutdownCsrProcess;
|
||||||
}
|
}
|
||||||
|
|
||||||
static NTSTATUS FASTCALL
|
static NTSTATUS FASTCALL
|
||||||
|
@ -718,6 +733,8 @@ UserClientShutdown(IN PCSR_PROCESS CsrProcess,
|
||||||
IN ULONG Flags,
|
IN ULONG Flags,
|
||||||
IN BOOLEAN FirstPhase)
|
IN BOOLEAN FirstPhase)
|
||||||
{
|
{
|
||||||
|
ULONG result;
|
||||||
|
|
||||||
DPRINT("UserClientShutdown(0x%p, 0x%x, %s) - [0x%x, 0x%x], ShutdownFlags: %lu\n",
|
DPRINT("UserClientShutdown(0x%p, 0x%x, %s) - [0x%x, 0x%x], ShutdownFlags: %lu\n",
|
||||||
CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
|
CsrProcess, Flags, FirstPhase ? "FirstPhase" : "LastPhase",
|
||||||
CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread,
|
CsrProcess->ClientId.UniqueProcess, CsrProcess->ClientId.UniqueThread,
|
||||||
|
@ -749,11 +766,12 @@ UserClientShutdown(IN PCSR_PROCESS CsrProcess,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify the process for shutdown if needed */
|
/* Notify the process for shutdown if needed */
|
||||||
if (!NotifyProcessForShutdown(CsrProcess, &ShutdownSettings, Flags))
|
result = NotifyUserProcessForShutdown(CsrProcess, &ShutdownSettings, Flags);
|
||||||
|
if (result == CsrShutdownCancelled || result == CsrShutdownNonCsrProcess)
|
||||||
{
|
{
|
||||||
DPRINT1("Process 0x%x aborted shutdown\n", CsrProcess->ClientId.UniqueProcess);
|
if (result == CsrShutdownCancelled)
|
||||||
/* Abort shutdown */
|
DPRINT1("Process 0x%x aborted shutdown\n", CsrProcess->ClientId.UniqueProcess);
|
||||||
return CsrShutdownCancelled;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Terminate this process */
|
/* Terminate this process */
|
||||||
|
|
Loading…
Reference in a new issue