Changeset 151098 in webkit
- Timestamp:
- Jun 3, 2013 1:34:34 AM (11 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r151091 r151098 1 2013-06-03 Sergio Correia <sergio.correia@openbossa.org> 2 3 [EFL][WK2] Process launcher uses system() for wrapping the WebProcess when using WEB_PROCESS_CMD_PREFIX 4 https://bugs.webkit.org/show_bug.cgi?id=105156 5 6 Reviewed by Christophe Dumez. 7 8 When using WEB_PROCESS_CMD_PREFIX - which allows us for instance to analyze 9 WebProcess under tools like valgrind or gdb -, the ProcessLauncher would 10 spawn the new process using system(), which would, among other things, keep 11 an extra UIProcess waiting and executing the shell. 12 13 This patch handles the normal case and the case where we have something to 14 prefix WebProcess (i.e., by using WEB_PROCESS_CMD_PREFIX in a debug build) 15 the same way, through a call to execvp(). 16 17 To achieve this a function was introduced to create an array with the given 18 arguments to the full command to be executed, to be used by execvp(). We use 19 a Vector<OwnArrayPtr<char>>, so that we can take advantage of the destructor 20 of OwnArrayPtr to handle the memory deallocation when it goes out of scope. 21 22 * UIProcess/Launcher/efl/ProcessLauncherEfl.cpp: 23 (WebKit::createArgsArray): This function creates the array to be used by 24 execvp(), out of the Strings given as arguments. 25 (WebKit::ProcessLauncher::launchProcess): Rework the logic to accomodate 26 both the cases with and without WEB_PROCESS_CMD_PREFIX. The execl() call 27 was replaced with an execvp() call, since now we should deal with having 28 a variable number of arguments (WEB_PROCESS_CMD_PREFIX) as well. 29 1 30 2013-06-02 Arunprasad Rajkumar <arurajku@cisco.com> 2 31 -
trunk/Source/WebKit2/UIProcess/Launcher/efl/ProcessLauncherEfl.cpp
r141275 r151098 1 1 /* 2 2 Copyright (C) 2012 Samsung Electronics 3 Copyright (C) 2013 Nokia Corporation and/or its subsidiary(-ies). 3 4 4 5 This library is free software; you can redistribute it and/or … … 28 29 #include <WebCore/ResourceHandle.h> 29 30 #include <WebCore/RunLoop.h> 31 #include <wtf/OwnArrayPtr.h> 30 32 #include <wtf/text/CString.h> 31 33 #include <wtf/text/WTFString.h> … … 34 36 35 37 namespace WebKit { 38 39 static Vector<OwnArrayPtr<char>> createArgsArray(const String& prefix, const String& executablePath, const String& socket, const String& pluginPath) 40 { 41 ASSERT(!executablePath.isEmpty()); 42 ASSERT(!socket.isEmpty()); 43 44 Vector<String> splitArgs; 45 prefix.split(' ', splitArgs); 46 47 splitArgs.append(executablePath); 48 splitArgs.append(socket); 49 if (!pluginPath.isEmpty()) 50 splitArgs.append(pluginPath); 51 52 Vector<OwnArrayPtr<char>> args; 53 args.resize(splitArgs.size() + 1); // Extra room for null. 54 55 size_t numArgs = splitArgs.size(); 56 for (size_t i = 0; i < numArgs; ++i) { 57 CString param = splitArgs[i].utf8(); 58 args[i] = adoptArrayPtr(new char[param.length() + 1]); // Room for the terminating null coming from the CString. 59 strncpy(args[i].get(), param.data(), param.length() + 1); // +1 here so that strncpy copies the ending null. 60 } 61 // execvp() needs the pointers' array to be null-terminated. 62 args[numArgs] = nullptr; 63 64 return args; 65 } 36 66 37 67 void ProcessLauncher::launchProcess() … … 43 73 } 44 74 45 CStringexecutablePath, pluginPath;75 String processCmdPrefix, executablePath, pluginPath; 46 76 switch (m_launchOptions.processType) { 47 77 case WebProcess: 48 executablePath = executablePathOfWebProcess() .utf8();78 executablePath = executablePathOfWebProcess(); 49 79 break; 50 80 #if ENABLE(PLUGIN_PROCESS) 51 81 case PluginProcess: 52 executablePath = executablePathOfPluginProcess() .utf8();53 pluginPath = m_launchOptions.extraInitializationData.get("plugin-path") .utf8();82 executablePath = executablePathOfPluginProcess(); 83 pluginPath = m_launchOptions.extraInitializationData.get("plugin-path"); 54 84 break; 55 85 #endif … … 59 89 } 60 90 61 char socket[5];62 snprintf(socket, sizeof(socket), "%d", sockets[0]);63 64 91 #ifndef NDEBUG 65 CString prefixedExecutablePath; 66 if (!m_launchOptions.processCmdPrefix.isEmpty()) { 67 String prefixedExecutablePathStr = m_launchOptions.processCmdPrefix + ' ' + 68 String::fromUTF8(executablePath.data()) + ' ' + socket + ' ' + String::fromUTF8(pluginPath.data()); 69 prefixedExecutablePath = prefixedExecutablePathStr.utf8(); 70 } 92 if (!m_launchOptions.processCmdPrefix.isEmpty()) 93 processCmdPrefix = m_launchOptions.processCmdPrefix; 71 94 #endif 95 Vector<OwnArrayPtr<char>> args = createArgsArray(processCmdPrefix, executablePath, String::number(sockets[0]), pluginPath); 72 96 73 97 // Do not perform memory allocation in the middle of the fork() … … 77 101 if (!pid) { // Child process. 78 102 close(sockets[1]); 79 #ifndef NDEBUG 80 if (!prefixedExecutablePath.isNull()) { 81 // FIXME: This is not correct because it invokes the shell 82 // and keeps this process waiting. Should be changed to 83 // something like execvp(). 84 if (system(prefixedExecutablePath.data()) == -1) { 85 ASSERT_NOT_REACHED(); 86 exit(EXIT_FAILURE); 87 } else 88 exit(EXIT_SUCCESS); 89 } 90 #endif 91 execl(executablePath.data(), executablePath.data(), socket, pluginPath.data(), static_cast<char*>(0)); 103 execvp(args.data()[0].get(), reinterpret_cast<char* const*>(args.data())); 92 104 } else if (pid > 0) { // parent process; 93 105 close(sockets[0]);
Note: See TracChangeset
for help on using the changeset viewer.