зеркало из https://github.com/mozilla/pjs.git
66735: implement blocking processes on the mac.
This commit is contained in:
Родитель
aaef4833f2
Коммит
debc13c693
|
@ -20,6 +20,7 @@
|
|||
*
|
||||
* Contributor(s):
|
||||
* Don Bragg <dbragg@netscape.com>
|
||||
* Samir Gehani <sgehani@netscape.com>
|
||||
*/
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -37,6 +38,7 @@
|
|||
|
||||
#include "prtypes.h"
|
||||
#include "prio.h"
|
||||
#include "prthread.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <Processes.h>
|
||||
|
@ -81,26 +83,54 @@ nsProcess::Init(nsIFile* executable)
|
|||
NS_IMETHODIMP
|
||||
nsProcess::Run(PRBool blocking, const char **args, PRUint32 count, PRUint32 *pid)
|
||||
{
|
||||
OSErr err = noErr;
|
||||
LaunchParamBlockRec launchPB;
|
||||
FSSpec* targetSpec;
|
||||
OSErr err = noErr;
|
||||
LaunchParamBlockRec launchPB;
|
||||
FSSpec resolvedSpec;
|
||||
Boolean bDone = false;
|
||||
ProcessInfoRec info;
|
||||
|
||||
nsCOMPtr<nsILocalFileMac> macExecutable = do_QueryInterface(mExecutable);
|
||||
macExecutable->GetFSSpec(targetSpec);
|
||||
|
||||
launchPB.launchAppSpec = targetSpec;
|
||||
launchPB.launchAppParameters = NULL;
|
||||
launchPB.launchBlockID = extendedBlock;
|
||||
launchPB.launchEPBLength = extendedBlockLen;
|
||||
launchPB.launchFileFlags = NULL;
|
||||
launchPB.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum;
|
||||
launchPB.launchControlFlags += launchDontSwitch;
|
||||
macExecutable->GetResolvedFSSpec(&resolvedSpec);
|
||||
|
||||
err = LaunchApplication(&launchPB);
|
||||
if (err != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
launchPB.launchAppSpec = &resolvedSpec;
|
||||
launchPB.launchAppParameters = NULL;
|
||||
launchPB.launchBlockID = extendedBlock;
|
||||
launchPB.launchEPBLength = extendedBlockLen;
|
||||
launchPB.launchFileFlags = NULL;
|
||||
launchPB.launchControlFlags = launchContinue + launchNoFileFlags + launchUseMinimum;
|
||||
if (!blocking)
|
||||
launchPB.launchControlFlags += launchDontSwitch;
|
||||
|
||||
err = LaunchApplication(&launchPB);
|
||||
if (err != noErr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
return NS_OK;
|
||||
// NOTE: blocking mode assumes you are running on a thread
|
||||
// other than the UI thread that has teh main event loop
|
||||
if (blocking)
|
||||
{
|
||||
do
|
||||
{
|
||||
info.processInfoLength = sizeof(ProcessInfoRec);
|
||||
info.processName = nil;
|
||||
info.processAppSpec = nil;
|
||||
err = GetProcessInformation(&launchPB.launchProcessSN, &info);
|
||||
|
||||
if (err == noErr)
|
||||
{
|
||||
// still running so sleep some more (200 msecs)
|
||||
PR_Sleep(200);
|
||||
}
|
||||
else
|
||||
{
|
||||
// no longer in process manager's internal list: so assume done
|
||||
bDone = true;
|
||||
}
|
||||
}
|
||||
while (!bDone);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsProcess::InitWithPid(PRUint32 pid)
|
||||
|
|
Загрузка…
Ссылка в новой задаче