Changeset 83277 in webkit
- Timestamp:
- Apr 8, 2011 3:06:24 AM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r83259 r83277 1 2011-04-08 Carlos Garcia Campos <cgarcia@igalia.com> 2 3 Reviewed by Martin Robinson. 4 5 [GTK] Use glib API instead of fork + execl in ProcessLauncherGtk 6 https://bugs.webkit.org/show_bug.cgi?id=57234 7 8 * UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp: 9 (WebKit::childSetupFunction): close the socket and use prctl() 10 when platform is Linux to kill the child process when the parent 11 finishes. 12 (WebKit::ProcessLauncher::launchProcess): Use g_spawn_async() to 13 launch the web process. 14 1 15 2011-04-07 Geoffrey Garen <ggaren@apple.com> 2 16 -
trunk/Source/WebKit2/UIProcess/Launcher/gtk/ProcessLauncherGtk.cpp
r83215 r83277 33 33 #include <WebCore/ResourceHandle.h> 34 34 #include <errno.h> 35 #include <stdio.h> 36 #include <unistd.h> 35 #if OS(LINUX) 36 #include <sys/prctl.h> 37 #endif 37 38 #include <wtf/text/CString.h> 38 39 #include <wtf/text/WTFString.h> … … 45 46 const char* gWebKitWebProcessName = "WebKitWebProcess"; 46 47 48 static void childSetupFunction(gpointer userData) 49 { 50 int socket = GPOINTER_TO_INT(userData); 51 close(socket); 52 53 #if OS(LINUX) 54 // Kill child process when parent dies. 55 prctl(PR_SET_PDEATHSIG, SIGKILL); 56 #endif 57 } 58 47 59 void ProcessLauncher::launchProcess() 48 60 { 49 pid_tpid = 0;61 GPid pid = 0; 50 62 51 63 int sockets[2]; 52 64 if (socketpair(AF_UNIX, SOCK_DGRAM, 0, sockets) < 0) { 53 fprintf(stderr, "Creation of socket failed with errno %d.\n", errno);65 g_printerr("Creation of socket failed: %s.\n", g_strerror(errno)); 54 66 ASSERT_NOT_REACHED(); 55 67 return; 56 68 } 57 69 58 pid = fork(); 59 if (!pid) { // child process 60 close(sockets[1]); 61 String socket = String::format("%d", sockets[0]); 62 GOwnPtr<gchar> binaryPath(g_build_filename(applicationDirectoryPath().data(), gWebKitWebProcessName, NULL)); 63 execl(binaryPath.get(), gWebKitWebProcessName, socket.utf8().data(), NULL); 64 } else if (pid > 0) { // parent process 65 close(sockets[0]); 66 m_processIdentifier = pid; 67 // We've finished launching the process, message back to the main run loop. 68 RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, pid, sockets[1])); 69 } else { 70 fprintf(stderr, "Unable to fork a new WebProcess with errno: %d.\n", errno); 70 GOwnPtr<gchar> binaryPath(g_build_filename(applicationDirectoryPath().data(), gWebKitWebProcessName, NULL)); 71 GOwnPtr<gchar> socket(g_strdup_printf("%d", sockets[0])); 72 char* argv[3]; 73 argv[0] = binaryPath.get(); 74 argv[1] = socket.get(); 75 argv[2] = 0; 76 77 GOwnPtr<GError> error; 78 int spawnFlags = G_SPAWN_LEAVE_DESCRIPTORS_OPEN | G_SPAWN_DO_NOT_REAP_CHILD; 79 if (!g_spawn_async(0, argv, 0, static_cast<GSpawnFlags>(spawnFlags), childSetupFunction, GINT_TO_POINTER(sockets[1]), &pid, &error.outPtr())) { 80 g_printerr("Unable to fork a new WebProcess: %s.\n", error->message); 71 81 ASSERT_NOT_REACHED(); 72 82 } 83 84 close(sockets[0]); 85 m_processIdentifier = static_cast<pid_t>(pid); 86 // We've finished launching the process, message back to the main run loop. 87 RunLoop::main()->scheduleWork(WorkItem::create(this, &ProcessLauncher::didFinishLaunchingProcess, m_processIdentifier, sockets[1])); 73 88 } 74 89
Note: See TracChangeset
for help on using the changeset viewer.