|
|
@@ -31,11 +31,25 @@ |
|
|
#include <Roster.h> |
|
|
#include <StackOrHeapArray.h> |
|
|
#include <String.h> |
|
|
#include <unistd.h> |
|
|
|
|
|
using namespace WebCore; |
|
|
|
|
|
namespace WebKit { |
|
|
|
|
|
status_t processRef(BString path, entry_ref* pathRef) |
|
|
{ |
|
|
BEntry pathEntry(path); |
|
|
if(!pathEntry.Exists()) |
|
|
return B_BAD_VALUE; |
|
|
|
|
|
status_t result = pathEntry.GetRef(pathRef); |
|
|
if(result != B_OK) |
|
|
return result; |
|
|
|
|
|
return B_OK; |
|
|
} |
|
|
|
|
|
void ProcessLauncher::launchProcess() |
|
|
{ |
|
|
BString executablePath; |
|
|
@@ -54,7 +68,9 @@ void ProcessLauncher::launchProcess() |
|
|
return; |
|
|
} |
|
|
|
|
|
BString processIdentifier; |
|
|
BString processIdentifier,processID; |
|
|
team_id UIProcessID = getpid(); |
|
|
processID.SetToFormat("%ld",UIProcessID); |
|
|
processIdentifier.SetToFormat("%" PRIu64, m_launchOptions.processIdentifier.toUInt64()); |
|
|
unsigned nargs = 5; // size of the argv array for g_spawn_async() |
|
|
|
|
|
@@ -67,6 +83,11 @@ void ProcessLauncher::launchProcess() |
|
|
} |
|
|
#endif |
|
|
|
|
|
entry_ref executableRef; |
|
|
if(processRef(executablePath,&executableRef)!=B_OK) |
|
|
{ |
|
|
return; |
|
|
} |
|
|
BStackOrHeapArray<const char*, 10> argv(nargs); |
|
|
unsigned i = 0; |
|
|
#if ENABLE(DEVELOPER_MODE) |
|
|
@@ -77,15 +98,16 @@ void ProcessLauncher::launchProcess() |
|
|
#endif |
|
|
argv[i++] = executablePath.String(); |
|
|
argv[i++] = processIdentifier.String(); |
|
|
argv[i++] = processID.String(); |
|
|
// TODO pass our team_id so the web process can message us? |
|
|
argv[i++] = nullptr; |
|
|
|
|
|
assert(i <= nargs); |
|
|
|
|
|
team_id child_id; // TODO do we need to store this somewhere? |
|
|
status_t result = be_roster->Launch(executablePath, i, argv, &child_id); |
|
|
status_t result = be_roster->Launch(&executableRef, i-1, argv, &child_id); |
|
|
|
|
|
fprintf(stderr, "%s: %s\n", __PRETTY_FUNCTION__, strerror(result)); |
|
|
fprintf(stderr, "%s: %s %ld\n", __PRETTY_FUNCTION__, strerror(result),child_id); |
|
|
|
|
|
// We've finished launching the process, message back to the main run loop. |
|
|
RunLoop::main().dispatch([protectedThis = makeRef(*this), this, child_id] { |
|
|
|