summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2009-03-08 13:25:12 +0100
committerDanny Baumann <dannybaumann@web.de>2009-03-08 13:25:12 +0100
commit9f4359ca78756858dae4507072ed838cb23a3ef8 (patch)
treed45ec7b0503795259e407358b71ee5ea694ea593 /src
parentd2ca4c19f1a3f470a8830c4ea36049f4bb4415cd (diff)
downloadmobilebling-9f4359ca78756858dae4507072ed838cb23a3ef8.tar.gz
mobilebling-9f4359ca78756858dae4507072ed838cb23a3ef8.tar.bz2
Also save process ID to session manager.
Diffstat (limited to 'src')
-rw-r--r--src/session.cpp43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/session.cpp b/src/session.cpp
index 0547ec8..885f0a6 100644
--- a/src/session.cpp
+++ b/src/session.cpp
@@ -142,21 +142,34 @@ setRestartStyle (SmcConn connection,
static void
setProgram (SmcConn connection,
- const char *program)
+ const char *program,
+ pid_t pid)
{
- SmProp prop, *pProp;
- SmPropValue propVal;
-
- prop.name = const_cast<char *> (SmProgram);
- prop.type = const_cast<char *> (SmARRAY8);
- prop.num_vals = 1;
- prop.vals = &propVal;
- propVal.value = (SmPointer) program;
- propVal.length = strlen (program);
-
- pProp = &prop;
-
- SmcSetProperties (connection, 1, &pProp);
+ SmProp progProp, pidProp;
+ SmPropValue progVal, pidVal;
+ SmProp *props[2];
+ char pidBuffer[32];
+
+ progProp.name = const_cast<char *> (SmProgram);
+ progProp.type = const_cast<char *> (SmARRAY8);
+ progProp.num_vals = 1;
+ progProp.vals = &progVal;
+ progVal.value = (SmPointer) program;
+ progVal.length = strlen (program);
+
+ snprintf (pidBuffer, sizeof (pidBuffer), "%d", pid);
+
+ pidProp.name = const_cast<char *> (SmProcessID);
+ pidProp.type = const_cast<char *> (SmARRAY8);
+ pidProp.num_vals = 1;
+ pidProp.vals = &pidVal;
+ pidVal.value = (SmPointer) pidBuffer;
+ pidVal.length = strlen (pidBuffer);
+
+ props[0] = &progProp;
+ props[1] = &pidProp;
+
+ SmcSetProperties (connection, 2, props);
}
static void
@@ -183,7 +196,7 @@ saveYourselfCallback (SmcConn connection,
setCloneRestartCommands (connection);
setRestartStyle (connection, SmRestartImmediately);
- setProgram (connection, programName);
+ setProgram (connection, programName, getpid ());
SmcSaveYourselfDone (connection, 1);
}