summaryrefslogtreecommitdiffstats
path: root/opensuse/core/tdelibs.old/oom_score_adj.patch
diff options
context:
space:
mode:
authorRobert Xu <robxu9@gmail.com>2012-03-31 14:28:06 -0400
committerRobert Xu <robxu9@gmail.com>2012-03-31 14:28:06 -0400
commit59dd46ef985a719579132efa6a9aa49bfeeae112 (patch)
tree93d8c721ff263e67aaf59e364496862872ded8fb /opensuse/core/tdelibs.old/oom_score_adj.patch
parentc141f0bc29b6e2eeda5ca08a043d26546a1427f9 (diff)
downloadtde-packaging-59dd46ef985a719579132efa6a9aa49bfeeae112.tar.gz
tde-packaging-59dd46ef985a719579132efa6a9aa49bfeeae112.zip
better late than never, hm...
Diffstat (limited to 'opensuse/core/tdelibs.old/oom_score_adj.patch')
-rw-r--r--opensuse/core/tdelibs.old/oom_score_adj.patch36
1 files changed, 36 insertions, 0 deletions
diff --git a/opensuse/core/tdelibs.old/oom_score_adj.patch b/opensuse/core/tdelibs.old/oom_score_adj.patch
new file mode 100644
index 000000000..f7a929f3f
--- /dev/null
+++ b/opensuse/core/tdelibs.old/oom_score_adj.patch
@@ -0,0 +1,36 @@
+Index: kdelibs-3.5.10/kinit/start_kdeinit.c
+===================================================================
+--- kdelibs-3.5.10.orig/kinit/start_kdeinit.c
++++ kdelibs-3.5.10/kinit/start_kdeinit.c
+@@ -44,11 +44,30 @@ static int set_protection( pid_t pid, in
+ {
+ 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;
+ }