1
0
mirror of https://github.com/Ylianst/MeshAgent synced 2025-12-15 15:53:55 +00:00

1. Updated MacOS, so detached child process uses fork instead of vfork

2. Updated detached to be a bitmask on the type
3. Updated MacOS message-box cleanup
This commit is contained in:
Bryan Roe
2019-06-04 13:06:17 -07:00
parent 3ab7316172
commit f15c11c845
5 changed files with 45 additions and 60 deletions

View File

@@ -751,6 +751,8 @@ void ILibProcessPipe_Process_SoftKill(ILibProcessPipe_Process p)
ILibProcessPipe_Process ILibProcessPipe_Manager_SpawnProcessEx4(ILibProcessPipe_Manager pipeManager, char* target, char* const* parameters, ILibProcessPipe_SpawnTypes spawnType, void *sid, void *envvars, int extraMemorySize)
{
ILibProcessPipe_Process_Object* retVal = NULL;
int needSetSid = ((spawnType & ILibProcessPipe_SpawnTypes_POSIX_DETACHED) == ILibProcessPipe_SpawnTypes_POSIX_DETACHED);
if (needSetSid != 0) { spawnType ^= ILibProcessPipe_SpawnTypes_POSIX_DETACHED; }
#ifdef WIN32
STARTUPINFOA info = { 0 };
@@ -760,10 +762,11 @@ ILibProcessPipe_Process ILibProcessPipe_Manager_SpawnProcessEx4(ILibProcessPipe_
DWORD sessionId;
HANDLE token = NULL, userToken = NULL, procHandle = NULL;
int allocParms = 0;
ZeroMemory(&processInfo, sizeof(PROCESS_INFORMATION));
ZeroMemory(&info, sizeof(STARTUPINFOA));
if (spawnType != ILibProcessPipe_SpawnTypes_SPECIFIED_USER && spawnType != ILibProcessPipe_SpawnTypes_DEFAULT && (sessionId = WTSGetActiveConsoleSessionId()) == 0xFFFFFFFF) { return(NULL); } // No session attached to console, but requested to execute as logged in user
if (spawnType != ILibProcessPipe_SpawnTypes_DEFAULT)
{
@@ -899,7 +902,18 @@ ILibProcessPipe_Process ILibProcessPipe_Manager_SpawnProcessEx4(ILibProcessPipe_
retVal->stdOut = ILibProcessPipe_CreatePipe(pipeManager, 4096, (ILibProcessPipe_GenericBrokenPipeHandler)ILibProcessPipe_Process_BrokenPipeSink, extraMemorySize);
retVal->stdOut->mProcess = retVal;
}
#ifdef __APPLE__
if (needSetSid == 0)
{
pid = vfork();
}
else
{
pid = fork();
}
#else
pid = vfork();
#endif
}
if (pid < 0)
{
@@ -942,7 +956,7 @@ ILibProcessPipe_Process ILibProcessPipe_Manager_SpawnProcessEx4(ILibProcessPipe_
{
ignore_result(setuid((uid_t)UID));
}
if (spawnType == ILibProcessPipe_SpawnTypes_POSIX_DETACHED)
if (needSetSid != 0)
{
ignore_result(setsid());
}
@@ -954,6 +968,7 @@ ILibProcessPipe_Process ILibProcessPipe_Manager_SpawnProcessEx4(ILibProcessPipe_
execv(target, parameters);
_exit(1);
}
if (spawnType != ILibProcessPipe_SpawnTypes_TERM && spawnType != ILibProcessPipe_SpawnTypes_DETACHED)
{
close(retVal->stdIn->mPipe_ReadEnd);