summaryrefslogtreecommitdiff
path: root/src/session.c
diff options
context:
space:
mode:
authorDanny Baumann <dannybaumann@web.de>2008-11-03 13:50:18 +0100
committerDanny Baumann <dannybaumann@web.de>2008-11-04 12:32:57 +0100
commit915d9362f678b82e8fd5c203b4e103cf12ce75a2 (patch)
tree408f4a1844ad8c909bba1401e65e055d0a59c88d /src/session.c
parent889be3f6bafc4b2c438316a7e64e754c812d5b45 (diff)
Also save process ID to session manager.
Diffstat (limited to 'src/session.c')
-rw-r--r--src/session.c43
1 files changed, 28 insertions, 15 deletions
diff --git a/src/session.c b/src/session.c
index 1d2422b0..4f0f118f 100644
--- a/src/session.c
+++ b/src/session.c
@@ -137,21 +137,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 = SmProgram;
- prop.type = 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 = SmProgram;
+ progProp.type = SmARRAY8;
+ progProp.num_vals = 1;
+ progProp.vals = &progVal;
+ progVal.value = (SmPointer) program;
+ progVal.length = strlen (program);
+
+ snprintf (pidBuffer, sizeof (pidBuffer), "%d", pid);
+
+ pidProp.name = SmProcessID;
+ pidProp.type = 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
@@ -184,7 +197,7 @@ saveYourselfCallback (SmcConn connection,
setCloneRestartCommands (connection);
setRestartStyle (connection, SmRestartImmediately);
- setProgram (connection, programName);
+ setProgram (connection, programName, getpid ());
SmcSaveYourselfDone (connection, 1);
}