You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by be...@apache.org on 2012/05/24 01:37:36 UTC
svn commit: r1342089 - in /incubator/mesos/trunk/src:
common/process_utils.hpp common/utils.hpp scripts/killtree.sh
slave/process_based_isolation_module.cpp
Author: benh
Date: Wed May 23 23:37:35 2012
New Revision: 1342089
URL: http://svn.apache.org/viewvc?rev=1342089&view=rev
Log:
Made killtree be more verbose (contributed by Vinod Kone, https://reviews.apache.org/r/5198).
Modified:
incubator/mesos/trunk/src/common/process_utils.hpp
incubator/mesos/trunk/src/common/utils.hpp
incubator/mesos/trunk/src/scripts/killtree.sh
incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
Modified: incubator/mesos/trunk/src/common/process_utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/process_utils.hpp?rev=1342089&r1=1342088&r2=1342089&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/process_utils.hpp (original)
+++ incubator/mesos/trunk/src/common/process_utils.hpp Wed May 23 23:37:35 2012
@@ -34,7 +34,8 @@ inline Try<int> killtree(
pid_t pid,
int signal,
bool killgroups,
- bool killsess)
+ bool killsess,
+ bool verbose)
{
std::string cmdline;
@@ -58,8 +59,9 @@ inline Try<int> killtree(
// Also add flags to kill all encountered groups and sessions.
if (killgroups) cmdline += " -g";
if (killsess) cmdline += " -x";
+ if (verbose) cmdline += " -v";
- return utils::os::shell(NULL, cmdline);
+ return utils::os::shell(verbose ? &LOG(INFO) : NULL, cmdline);
}
} // namespace mesos {
Modified: incubator/mesos/trunk/src/common/utils.hpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/common/utils.hpp?rev=1342089&r1=1342088&r2=1342089&view=diff
==============================================================================
--- incubator/mesos/trunk/src/common/utils.hpp (original)
+++ incubator/mesos/trunk/src/common/utils.hpp Wed May 23 23:37:35 2012
@@ -443,7 +443,8 @@ inline Result<std::string> hostname()
// Runs a shell command formatted with varargs and return the return value
// of the command. Optionally, the output is returned via an argument.
-inline Try<int> shell(std::iostream* ios, const std::string& fmt, ...)
+// TODO(vinod): Pass an istream object that can provide input to the command.
+inline Try<int> shell(std::ostream* os, const std::string& fmt, ...)
{
va_list args;
va_start(args, fmt);
@@ -466,8 +467,8 @@ inline Try<int> shell(std::iostream* ios
// NOTE(vinod): Ideally the if and while loops should be interchanged. But
// we get a broken pipe error if we don't read the output and simply close.
while (fgets(line, sizeof(line), file) != NULL) {
- if (ios != NULL) {
- *ios << line ;
+ if (os != NULL) {
+ *os << line ;
}
}
Modified: incubator/mesos/trunk/src/scripts/killtree.sh
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/scripts/killtree.sh?rev=1342089&r1=1342088&r2=1342089&view=diff
==============================================================================
--- incubator/mesos/trunk/src/scripts/killtree.sh (original)
+++ incubator/mesos/trunk/src/scripts/killtree.sh Wed May 23 23:37:35 2012
@@ -116,6 +116,14 @@ if [[ ${?} -ne 0 ]]; then
exit 1
fi
+printpids() {
+ name="$1"
+ tpids="$2"
+ if [[ ! -z ${tpids} ]]; then
+ result=$(echo ${tpids} | xargs ps xo pid,ppid,pgid,sess,command -p)
+ printf "\n${name}\n${result}\n"
+ fi
+}
PIDS=${PID} # Already processed pids, global variable hack.
@@ -124,7 +132,7 @@ killtree() {
# Output pid if requested.
if [[ ${VERBOSE} -eq 1 ]]; then
- printf "\nkilltree on ${MYPID}\n"
+ printpids "KILLPID" ${MYPID}
fi
# Stop the process to keep it from forking while we are killing it
@@ -152,6 +160,10 @@ killtree() {
# Now collect all the children.
CHILDPIDS=$(ps axo ppid,pid | awk '{ if ($1 == '${MYPID}') print $2 }')
+ if [[ ${VERBOSE} -eq 1 ]]; then
+ printpids "CHILDPIDS" "${CHILDPIDS}"
+ fi
+
# Optionally collect all processes that are part of the process group.
GROUPPIDS=""
if [[ ${KILLGROUPS} -eq 1 ]]; then
@@ -163,6 +175,10 @@ killtree() {
# Now get all members.
GROUPPIDS=$(ps axo pgid,pid \
| awk '{ if ($1 == '${MYPGID}') print $2 }')
+
+ if [[ ${VERBOSE} -eq 1 ]]; then
+ printpids "GROUPPIDS" "${GROUPPIDS}"
+ fi
fi
fi
@@ -177,6 +193,10 @@ killtree() {
# Now get all members.
SESSPIDS=$(ps axo sess,pid \
| awk '{ if ($1 == "'${MYPSID}'") print $2 }')
+
+ if [[ ${VERBOSE} -eq 1 ]]; then
+ printpids "SESSPIDS" "${SESSPIDS}"
+ fi
fi
fi
Modified: incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp
URL: http://svn.apache.org/viewvc/incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp?rev=1342089&r1=1342088&r2=1342089&view=diff
==============================================================================
--- incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp (original)
+++ incubator/mesos/trunk/src/slave/process_based_isolation_module.cpp Wed May 23 23:37:35 2012
@@ -155,7 +155,7 @@ void ProcessBasedIsolationModule::killEx
// TODO(vinod): Call killtree on the pid of the actual executor process
// that is running the tasks (stored in the local storage by the
// executor module).
- utils::process::killtree(pid, SIGKILL, true, true);
+ utils::process::killtree(pid, SIGKILL, true, true, true);
ProcessInfo* info = infos[frameworkId][executorId];