summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);
}