summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Christian <andrew.christian@nokia.com>2012-07-06 11:21:53 -0400
committerChris Craig <craig@ics.com>2012-07-11 19:40:14 +0200
commit0455e15aedd8c94774638d696b716848387b688f (patch)
tree76ebe02093e49d57bae1fb7e7ee3c8632d02f669
parent0e530765b7cf081e655434db8a2a5fcf8174a72c (diff)
Updated to work with Bionic
Change-Id: Ied9ff13e8a467f9a7af6e9406518acdbba3474ec Reviewed-by: Chris Craig <craig@ics.com>
-rw-r--r--src/core/core.pro5
-rw-r--r--src/core/cpuidledelegate.cpp4
-rw-r--r--src/core/forklauncher.cpp9
-rw-r--r--src/core/launcherclient.cpp4
-rw-r--r--src/core/prefork.cpp10
-rw-r--r--src/core/prefork.h6
-rw-r--r--src/core/preforkprocessbackendfactory.cpp2
-rw-r--r--src/core/remoteprocessbackend.cpp8
-rw-r--r--src/core/remoteprotocol.h5
-rw-r--r--src/core/unixsandboxprocess.cpp4
-rw-r--r--tests/auto/processmanager/testClient/testClient.cpp1
-rw-r--r--tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp6
12 files changed, 41 insertions, 23 deletions
diff --git a/src/core/core.pro b/src/core/core.pro
index 8a6a3c1..0ef28b5 100644
--- a/src/core/core.pro
+++ b/src/core/core.pro
@@ -12,9 +12,10 @@ DEFINES += QT_ADDON_PROCESSMANAGER_LIB
CONFIG += module create_prl
MODULE_PRI = ../../modules/qt_processmanager.pri
-QMAKE_CXXFLAGS += -fPIC -fvisibility=hidden -fvisibility-inlines-hidden
+QMAKE_CXXFLAGS += -fPIC -fvisibility-inlines-hidden
LIBS += -ldl
-linux*: LIBS += -lcap
+
+linux*:!CONFIG(bionic): LIBS += -lcap
include($$PWD/core-lib.pri)
diff --git a/src/core/cpuidledelegate.cpp b/src/core/cpuidledelegate.cpp
index 4dd25fa..7ecef6c 100644
--- a/src/core/cpuidledelegate.cpp
+++ b/src/core/cpuidledelegate.cpp
@@ -45,6 +45,10 @@
#include <mach/processor_info.h>
#endif
+#if defined(Q_OS_LINUX_ANDROID)
+#include <ctype.h>
+#endif
+
#include "cpuidledelegate.h"
QT_BEGIN_NAMESPACE_PROCESSMANAGER
diff --git a/src/core/forklauncher.cpp b/src/core/forklauncher.cpp
index 4c37c1f..e3bd334 100644
--- a/src/core/forklauncher.cpp
+++ b/src/core/forklauncher.cpp
@@ -216,10 +216,13 @@ static void fixProcessState(const ProcessInfo& info, int *argc_ptr, char ***argv
uint umask = info.umask();
if (umask)
::umask(umask);
- struct passwd *pw = getpwent();
+#if !defined(Q_OS_LINUX_ANDROID)
+ // Bionic does not have a getpwent() function
+ struct passwd *pw = ::getpwent();
if (pw)
::initgroups(pw->pw_name, pw->pw_gid);
else
+#endif
::setgroups(0,0);
if (info.contains(ProcessInfoConstants::Priority)) {
@@ -372,12 +375,12 @@ void ChildProcess::processFdSet(QByteArray& outgoing, fd_set& rfds, fd_set& wfds
if (FD_ISSET(m_stdout, &rfds)) { // Data to read
readToBuffer(m_stdout, m_outbuf);
if (m_outbuf.size())
- copyToOutgoing(outgoing, RemoteProtocol::stdout(), m_outbuf, m_id);
+ copyToOutgoing(outgoing, RemoteProtocol::standardout(), m_outbuf, m_id);
}
if (FD_ISSET(m_stderr, &rfds)) { // Data to read
readToBuffer(m_stderr, m_errbuf);
if (m_errbuf.size())
- copyToOutgoing(outgoing, RemoteProtocol::stderr(), m_errbuf, m_id);
+ copyToOutgoing(outgoing, RemoteProtocol::standarderror(), m_errbuf, m_id);
}
if (m_state == SentSigTerm && m_timer.hasExpired(m_timeout)) {
m_state = SentSigKill;
diff --git a/src/core/launcherclient.cpp b/src/core/launcherclient.cpp
index bd3d1b8..1886f69 100644
--- a/src/core/launcherclient.cpp
+++ b/src/core/launcherclient.cpp
@@ -183,7 +183,7 @@ void LauncherClient::standardOutput(const QByteArray& data)
QJsonObject msg;
msg.insert(RemoteProtocol::event(), RemoteProtocol::output());
msg.insert(RemoteProtocol::id(), m_backendToId.value(backend));
- msg.insert(RemoteProtocol::stdout(), QString::fromLocal8Bit(data.data(), data.size()));
+ msg.insert(RemoteProtocol::standardout(), QString::fromLocal8Bit(data.data(), data.size()));
emit send(msg);
}
@@ -197,7 +197,7 @@ void LauncherClient::standardError(const QByteArray& data)
QJsonObject msg;
msg.insert(RemoteProtocol::event(), RemoteProtocol::output());
msg.insert(RemoteProtocol::id(), m_backendToId.value(backend));
- msg.insert(RemoteProtocol::stderr(), QString::fromLocal8Bit(data.data(), data.size()));
+ msg.insert(RemoteProtocol::standarderror(), QString::fromLocal8Bit(data.data(), data.size()));
emit send(msg);
}
diff --git a/src/core/prefork.cpp b/src/core/prefork.cpp
index 3484c4f..eae8495 100644
--- a/src/core/prefork.cpp
+++ b/src/core/prefork.cpp
@@ -235,9 +235,9 @@ int Prefork::makeChild(int start)
}
else {
// Parent
- m_children[m_count].stdin = fd1[1]; // Stdin of the child (write to this)
- m_children[m_count].stdout = fd2[0]; // Stdout of the child (read from this)
- m_children[m_count].pid = pid;
+ m_children[m_count].in = fd1[1]; // Stdin of the child (write to this)
+ m_children[m_count].out = fd2[0]; // Stdout of the child (read from this)
+ m_children[m_count].pid = pid;
m_count++;
::close(fd1[0]);
::close(fd2[1]);
@@ -335,12 +335,12 @@ const PreforkChildData *Prefork::at(int i) const
*/
/*!
- \variable PreforkChildData::stdin
+ \variable PreforkChildData::in
\brief The file descriptor of the child's stdin (write to this)
*/
/*!
- \variable PreforkChildData::stdout
+ \variable PreforkChildData::out
\brief The file descriptor of the child's stdout (read from this)
*/
diff --git a/src/core/prefork.h b/src/core/prefork.h
index a46090e..925bb93 100644
--- a/src/core/prefork.h
+++ b/src/core/prefork.h
@@ -45,9 +45,9 @@
QT_BEGIN_NAMESPACE_PROCESSMANAGER
struct Q_ADDON_PROCESSMANAGER_EXPORT PreforkChildData {
- int stdin; // Child stdin (write to this)
- int stdout; // Child stdout (read from this)
- int pid; // Child process ID
+ int in; // Child stdin (write to this)
+ int out; // Child stdout (read from this)
+ int pid; // Child process ID
};
class Q_ADDON_PROCESSMANAGER_EXPORT Prefork {
diff --git a/src/core/preforkprocessbackendfactory.cpp b/src/core/preforkprocessbackendfactory.cpp
index a01fb97..656e990 100644
--- a/src/core/preforkprocessbackendfactory.cpp
+++ b/src/core/preforkprocessbackendfactory.cpp
@@ -123,7 +123,7 @@ void PreforkProcessBackendFactory::setIndex(int index)
if (index >= 0 && index < prefork->size()) {
m_index = index;
const PreforkChildData *data = prefork->at(index);
- m_pipe->setFds(data->stdout, data->stdin);
+ m_pipe->setFds(data->out, data->in);
emit indexChanged();
}
else
diff --git a/src/core/remoteprocessbackend.cpp b/src/core/remoteprocessbackend.cpp
index 6cd260b..db8d344 100644
--- a/src/core/remoteprocessbackend.cpp
+++ b/src/core/remoteprocessbackend.cpp
@@ -259,11 +259,11 @@ void RemoteProcessBackend::receive(const QJsonObject& message)
emit stateChanged(m_state);
}
else if (event == RemoteProtocol::output()) {
- if (message.contains(RemoteProtocol::stdout())) {
- handleStandardOutput(message.value(RemoteProtocol::stdout()).toString().toLocal8Bit());
+ if (message.contains(RemoteProtocol::standardout())) {
+ handleStandardOutput(message.value(RemoteProtocol::standardout()).toString().toLocal8Bit());
}
- if (message.contains(RemoteProtocol::stderr())) {
- handleStandardError(message.value(RemoteProtocol::stderr()).toString().toLocal8Bit());
+ if (message.contains(RemoteProtocol::standarderror())) {
+ handleStandardError(message.value(RemoteProtocol::standarderror()).toString().toLocal8Bit());
}
}
else
diff --git a/src/core/remoteprotocol.h b/src/core/remoteprotocol.h
index c469a38..ed91e8d 100644
--- a/src/core/remoteprotocol.h
+++ b/src/core/remoteprotocol.h
@@ -79,8 +79,9 @@ public:
static inline const QString start() { return QStringLiteral("start"); }
static inline const QString started() { return QStringLiteral("started"); }
static inline const QString stateChanged() { return QStringLiteral("stateChanged"); }
- static inline const QString stderr() { return QStringLiteral("stderr"); }
- static inline const QString stdout() { return QStringLiteral("stdout"); }
+ // Under Bionic, stderr & stdout are macros, so they can't be used as function names
+ static inline const QString standarderror() { return QStringLiteral("stderr"); }
+ static inline const QString standardout() { return QStringLiteral("stdout"); }
static inline const QString stop() { return QStringLiteral("stop"); }
static inline const QString timeout() { return QStringLiteral("timeout"); }
static inline const QString value() { return QStringLiteral("value"); }
diff --git a/src/core/unixsandboxprocess.cpp b/src/core/unixsandboxprocess.cpp
index 24966e9..a1a70e2 100644
--- a/src/core/unixsandboxprocess.cpp
+++ b/src/core/unixsandboxprocess.cpp
@@ -47,7 +47,9 @@
#include <unistd.h>
#include <grp.h>
#include <sys/prctl.h>
+#if !defined(Q_OS_LINUX_ANDROID)
#include <sys/capability.h>
+#endif
#include <signal.h>
#endif
#include <pwd.h>
@@ -177,7 +179,7 @@ void UnixSandboxProcess::setupChildProcess()
}
-#if defined (Q_OS_LINUX)
+#if defined (Q_OS_LINUX) && !defined(Q_OS_LINUX_ANDROID)
if (m_dropCapabilities >= 0) {
cap_t caps;
cap_value_t cap_list[63];
diff --git a/tests/auto/processmanager/testClient/testClient.cpp b/tests/auto/processmanager/testClient/testClient.cpp
index 28c6f74..6460008 100644
--- a/tests/auto/processmanager/testClient/testClient.cpp
+++ b/tests/auto/processmanager/testClient/testClient.cpp
@@ -81,6 +81,7 @@ void * work(void *)
while (1)
sleep(1);
pthread_exit((void *)0);
+ return 0;
}
static char tough[] = "tough\n";
diff --git a/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp b/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp
index a8b5138..ca3f4e1 100644
--- a/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp
+++ b/tests/auto/processmanager/testPrelaunch/testPrelaunch.cpp
@@ -82,6 +82,8 @@ public:
::setgid(gid);
if (uid >= 0)
::setuid(uid);
+#if !defined(Q_OS_LINUX_ANDROID)
+ // Bionic does not have a getpwent() function defined
struct passwd * pw = getpwent();
if (pw)
::initgroups(pw->pw_name, pw->pw_gid);
@@ -89,6 +91,9 @@ public:
qWarning() << "Unable to find UID" << ::getuid() << "to set groups";
::setgroups(0,0);
}
+#else
+ ::setgroups(0,0);
+#endif
}
else {
QString cmd = object.value("command").toString();
@@ -163,6 +168,7 @@ void * work(void *)
while (1)
sleep(1);
pthread_exit((void *)0);
+ return 0;
}
int