public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] getrusage sucks
@ 2005-11-10 22:34 Claudio Scordino
  2005-11-11  5:06 ` David Wagner
  2005-11-12 17:45 ` How to quickly detect the mode change of a hard disk? Hui Cheng
  0 siblings, 2 replies; 10+ messages in thread
From: Claudio Scordino @ 2005-11-10 22:34 UTC (permalink / raw)
  To: linux-kernel, kernelnewbies

Does exist any _real_ reason why getrusage can't be invoked by a task to know 
statistics of another task ?

The changes would be very trivial, as shown by the following patch.

              Claudio


diff --git a/kernel/sys.c b/kernel/sys.c
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1746,9 +1746,13 @@ int getrusage(struct task_struct *p, int

 asmlinkage long sys_getrusage(int who, struct rusage __user *ru)
 {
-  if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN)
-     return -EINVAL;
-  return getrusage(current, who, ru);
+  if (who != RUSAGE_SELF && who != RUSAGE_CHILDREN) {
+      struct task_struct* tsk = find_task_by_pid(who);
+      if (tsk == NULL)
+        return -EINVAL;
+     return getrusage(tsk, RUSAGE_SELF, ru);
+   } else
+     return getrusage(current, who, ru);
 }

 asmlinkage long sys_umask(int mask)

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2005-11-22 15:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-10 22:34 [PATCH] getrusage sucks Claudio Scordino
2005-11-11  5:06 ` David Wagner
2005-11-11 19:09   ` Lee Revell
2005-11-11 19:13     ` David Wagner
2005-11-12 17:45 ` How to quickly detect the mode change of a hard disk? Hui Cheng
2005-11-13 15:10   ` Pavel Machek
2005-11-16 18:58     ` Alejandro Bonilla
2005-11-18 19:41       ` Hui Cheng
2005-11-19 23:44         ` Pavel Machek
2005-11-22 15:39           ` Hui Cheng

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox