#include <WebCore/FileSystem.h>
#include <wtf/text/CString.h>
#include <wtf/text/WTFString.h>
-#if PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT))
+#if PLATFORM(GTK) || PLATFORM(EFL)
#include <glib.h>
#endif
namespace WebKit {
+void PluginProcessProxy::platformInitializeLaunchOptions(ProcessLauncher::LaunchOptions& launchOptions, const PluginModuleInfo& pluginInfo)
+{
+#if PLATFORM(EFL) && !defined(NDEBUG)
+ const char* commandPrefix = getenv("PLUGIN_PROCESS_COMMAND_PREFIX");
+ if (commandPrefix && *commandPrefix)
+ launchOptions.processCmdPrefix = String::fromUTF8(commandPrefix);
+#endif
+
+ launchOptions.extraInitializationData.add("plugin-path", pluginInfo.path);
+}
+
void PluginProcessProxy::platformInitializePluginProcess(PluginProcessCreationParameters&)
{
}
bool PluginProcessProxy::scanPlugin(const String& pluginPath, RawPluginMetaData& result)
{
-#if PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT))
+#if PLATFORM(GTK) || PLATFORM(EFL)
CString binaryPath = fileSystemRepresentation(executablePathOfPluginProcess());
CString pluginPathCString = fileSystemRepresentation(pluginPath);
char* argv[4];
int status;
char* stdOut = 0;
+ // If the disposition of SIGCLD signal is set to SIG_IGN (default)
+ // then the signal will be ignored and g_spawn_sync() will not be
+ // able to return the status.
+ // As a consequence, we make sure that the disposition is set to
+ // SIG_DFL before calling g_spawn_sync().
+ struct sigaction action;
+ sigaction(SIGCLD, 0, &action);
+ if (action.sa_handler == SIG_IGN) {
+ action.sa_handler = SIG_DFL;
+ sigaction(SIGCLD, &action, 0);
+ }
+
if (!g_spawn_sync(0, argv, 0, G_SPAWN_STDERR_TO_DEV_NULL, 0, 0, &stdOut, 0, &status, 0))
return false;
- if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS) {
+ if (!WIFEXITED(status) || WEXITSTATUS(status) != EXIT_SUCCESS || !stdOut) {
free(stdOut);
return false;
}
- const unsigned kNumLinesExpected = 3;
- String lines[kNumLinesExpected];
- unsigned lineIndex = 0;
-
- const UChar* current = reinterpret_cast<const UChar*>(stdOut);
+ String stdOutString(reinterpret_cast<const UChar*>(stdOut));
+ free(stdOut);
- while (lineIndex < kNumLinesExpected) {
- const UChar* start = current;
- while (*current++ != UChar('\n')) { }
- lines[lineIndex++] = String(start, current - start - 1);
- }
+ Vector<String> lines;
+ stdOutString.split(UChar('\n'), true, lines);
- if (stdOut)
- free(stdOut);
+ if (lines.size() < 3)
+ return false;
result.name.swap(lines[0]);
result.description.swap(lines[1]);
result.mimeDescription.swap(lines[2]);
return !result.mimeDescription.isEmpty();
-#else // PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT))
+#else // PLATFORM(GTK) || PLATFORM(EFL)
return false;
-#endif // PLATFORM(GTK) || (PLATFORM(EFL) && ENABLE(GLIB_SUPPORT))
+#endif // PLATFORM(GTK) || PLATFORM(EFL)
}
} // namespace WebKit