summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-02-21 18:45:09 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2011-02-21 18:45:09 +0000
commitf0023a8307d74fa725424821433582eea645a4c5 (patch)
treef7f79d3c7ea383249ffec88ff732dc6e8a376934
parent374d939d8af431477ce2601815f0ba121b66871c (diff)
downloadtdelibs-f0023a8307d74fa725424821433582eea645a4c5.tar.gz
tdelibs-f0023a8307d74fa725424821433582eea645a4c5.zip
Support kernel >= 2.6.36
Thanks to Novell and Ilya git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdelibs@1222098 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
-rw-r--r--kinit/start_kdeinit.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/kinit/start_kdeinit.c b/kinit/start_kdeinit.c
index 722f3e97f..a86b366e5 100644
--- a/kinit/start_kdeinit.c
+++ b/kinit/start_kdeinit.c
@@ -44,11 +44,30 @@ static int set_protection( pid_t pid, int enable )
{
char buf[ 1024 ];
int procfile;
+ struct stat st;
+
+ /* Newer kernels (noticed in 2.6.36) */
+ sprintf( buf, "/proc/%d/oom_score_adj", pid );
+ if ( lstat (buf, &st) == 0) {
+ if( !enable ) {
+ /* Be paranoid and check that the pid we got from the pipe
+ belongs to this user. */
+ if( st.st_uid != getuid())
+ return 0;
+ }
+ procfile = open(buf, O_WRONLY);
+ if( enable )
+ write( procfile, "-300", sizeof( "-300" ));
+ else
+ write( procfile, "0", sizeof( "0" ));
+ close( procfile );
+ return 1;
+ }
+
sprintf( buf, "/proc/%d/stat", pid );
if( !enable ) {
/* Be paranoid and check that the pid we got from the pipe
belongs to this user. */
- struct stat st;
if( lstat( buf, &st ) < 0 || st.st_uid != getuid())
return 0;
}