diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-09-18 01:23:55 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2011-09-18 01:23:55 +0000 |
commit | 5118af588a78da1b40de35d3e1cf2b8e860b4d2a (patch) | |
tree | 6ada398867e52c25adce831a80fcdeac264ca7a1 /kdmlib | |
parent | 291dece245f84640199fd098123a28ca021404ea (diff) | |
download | tdebase-5118af588a78da1b40de35d3e1cf2b8e860b4d2a.tar.gz tdebase-5118af588a78da1b40de35d3e1cf2b8e860b4d2a.zip |
Fix kdmctl spamming by kdmsak
Fix KDM SAK passing to non-active VTs
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdebase@1254120 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kdmlib')
-rw-r--r-- | kdmlib/kdmtsak.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/kdmlib/kdmtsak.cpp b/kdmlib/kdmtsak.cpp index c1ef5d12f..10b8c1acf 100644 --- a/kdmlib/kdmtsak.cpp +++ b/kdmlib/kdmtsak.cpp @@ -71,6 +71,18 @@ bool is_vt_active() { } } else { + // See if the current session is local + // If it is, then the VT is not currently active and the SAK must be requested later when it is active + for ( TQStringList::Iterator it = sessionList.begin(); it != sessionList.end(); ++it ) { + TQStringList sessionInfoList = TQStringList::split(',', *it, true); + if ((*(sessionInfoList.at(0))).startsWith(":")) { + if (TQString(currentDisplay).startsWith(*(sessionInfoList.at(0)))) { + return false; + } + } + } + // Hmm, not local + // Do not reject the SAK return true; } } @@ -92,6 +104,7 @@ int main (int argc, char *argv[]) while (numread > 0) { numread = read(mPipe_fd, readbuf, 6); } + close(mPipe_fd); // Now wait for SAK press mPipe_fd = open(FIFO_FILE, O_RDWR); while (mPipe_fd > -1) { @@ -99,12 +112,19 @@ int main (int argc, char *argv[]) readbuf[numread] = 0; readbuf[127] = 0; if (strcmp(readbuf, "SAK\n\r") == 0) { + close(mPipe_fd); if (is_vt_active()) { - close(mPipe_fd); return 0; } else { usleep(100); + // Flush the buffer + mPipe_fd = open(FIFO_FILE, O_RDWR | O_NONBLOCK); + numread = 1; + while (numread > 0) { + numread = read(mPipe_fd, readbuf, 6); + } + mPipe_fd = open(FIFO_FILE, O_RDWR); } } else { |