Commit 8ec9399f authored by Roland McGrath's avatar Roland McGrath Committed by Linus Torvalds

[PATCH] back out siginfo_t.si_rusage from waitid changes

As I explained in the waitid patches, I added the si_rusage field to
siginfo_t with the idea of having the siginfo_t waitid fills in contain all
the information that wait4 or any such call could ever tell you.  Nowhere
in POSIX nor anywhere else specifies this field in siginfo_t.  

When Ulrich and I hashed out the system call interface we wanted, we looked
at siginfo_t and decided there was plenty of space to throw in si_rusage.
Well, it turns out we didn't check the 64-bit platforms.  There struct
rusage is ridiculously large (lots of longs for things that are never in a
million years going to hit 2^32), and my changes bumped up the size of
siginfo_t.  Changing that size is more trouble than it's worth.

This patch reverts the changes to the siginfo_t structure types,
and no longer provides the rusage details in SIGCHLD signal data.
Instead, I added a fifth argument to the waitid system call to fill in rusage.

waitid is the name of the POSIX function with four arguments.  It might
make sense to rename the system call `waitsys' to follow SGI's system call
with the same arguments, or `wait5' in the mindless tradition.  But, feh.
I just added the argument to sys_waitid, rather than worrying about
changing the name in all the tables (and choosing a new stupid name).
Signed-off-by: default avatarRoland McGrath <roland@redhat.com>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 4de1e874
......@@ -122,7 +122,6 @@ struct siginfo32 {
int _status; /* exit code */
compat_clock_t _utime;
compat_clock_t _stime;
struct compat_rusage _rusage;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGEMT */
......@@ -188,8 +187,6 @@ int copy_siginfo_to_user32(struct siginfo32 __user *to, siginfo_t *from)
err |= __put_user(from->si_utime, &to->si_utime);
err |= __put_user(from->si_stime, &to->si_stime);
err |= __put_user(from->si_status, &to->si_status);
err |= put_compat_rusage(&from->si_rusage,
&to->si_rusage);
default:
err |= __put_user(from->si_pid, &to->si_pid);
err |= __put_user(from->si_uid, &to->si_uid);
......
......@@ -74,8 +74,6 @@ int ia32_copy_siginfo_to_user(siginfo_t32 __user *to, siginfo_t *from)
err |= __put_user(from->si_utime, &to->si_utime);
err |= __put_user(from->si_stime, &to->si_stime);
err |= __put_user(from->si_status, &to->si_status);
err |= put_compat_rusage(&from->si_rusage,
&to->si_rusage);
default:
case __SI_KILL >> 16:
err |= __put_user(from->si_uid, &to->si_uid);
......
......@@ -75,7 +75,6 @@ typedef struct siginfo {
int _status; /* exit code */
clock_t _utime;
clock_t _stime;
struct rusage _rusage;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
......@@ -107,7 +106,6 @@ typedef struct siginfo {
#define si_status _sifields._sigchld._status
#define si_utime _sifields._sigchld._utime
#define si_stime _sifields._sigchld._stime
#define si_rusage _sifields._sigchld._rusage
#define si_value _sifields._rt._sigval
#define si_int _sifields._rt._sigval.sival_int
#define si_ptr _sifields._rt._sigval.sival_ptr
......
......@@ -56,7 +56,6 @@ typedef struct siginfo {
int _status; /* exit code */
clock_t _utime;
clock_t _stime;
struct rusage _rusage;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
......
......@@ -115,7 +115,6 @@ typedef struct siginfo32 {
int _status; /* exit code */
compat_clock_t _utime;
compat_clock_t _stime;
struct compat_rusage _rusage;
} _sigchld;
/* SIGILL, SIGFPE, SIGSEGV, SIGBUS */
......
......@@ -949,9 +949,10 @@ static int eligible_child(pid_t pid, int options, task_t *p)
static int wait_noreap_copyout(task_t *p, pid_t pid, uid_t uid,
int why, int status,
struct siginfo __user *infop)
struct siginfo __user *infop,
struct rusage __user *rusagep)
{
int retval = getrusage(p, RUSAGE_BOTH, &infop->si_rusage);
int retval = rusagep ? getrusage(p, RUSAGE_BOTH, rusagep) : 0;
put_task_struct(p);
if (!retval)
retval = put_user(SIGCHLD, &infop->si_signo);
......@@ -1003,7 +1004,8 @@ static int wait_task_zombie(task_t *p, int noreap,
why = (exit_code & 0x80) ? CLD_DUMPED : CLD_KILLED;
status = exit_code & 0x7f;
}
return wait_noreap_copyout(p, pid, uid, why, status, infop);
return wait_noreap_copyout(p, pid, uid, why,
status, infop, ru);
}
/*
......@@ -1161,7 +1163,7 @@ static int wait_task_stopped(task_t *p, int delayed_group_leader, int noreap,
goto bail_ref;
return wait_noreap_copyout(p, pid, uid,
why, (exit_code << 8) | 0x7f,
infop);
infop, ru);
}
write_lock_irq(&tasklist_lock);
......@@ -1304,7 +1306,7 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
read_unlock(&tasklist_lock);
retval = wait_noreap_copyout(p, pid,
uid, CLD_CONTINUED,
SIGCONT, infop);
SIGCONT, infop, ru);
BUG_ON(retval == 0);
goto end;
}
......@@ -1371,7 +1373,8 @@ static long do_wait(pid_t pid, int options, struct siginfo __user *infop,
}
asmlinkage long sys_waitid(int which, pid_t pid,
struct siginfo __user *infop, int options)
struct siginfo __user *infop, int options,
struct rusage __user *ru)
{
if (options & ~(WNOHANG|WNOWAIT|WEXITED|WSTOPPED|WCONTINUED))
return -EINVAL;
......@@ -1395,7 +1398,7 @@ asmlinkage long sys_waitid(int which, pid_t pid,
return -EINVAL;
}
return do_wait(pid, options, infop, NULL, &infop->si_rusage);
return do_wait(pid, options, infop, NULL, ru);
}
asmlinkage long sys_wait4(pid_t pid, unsigned int __user *stat_addr,
......
......@@ -1500,7 +1500,6 @@ void do_notify_parent(struct task_struct *tsk, int sig)
/* FIXME: find out whether or not this is supposed to be c*time. */
info.si_utime = tsk->utime + tsk->signal->utime;
info.si_stime = tsk->stime + tsk->signal->stime;
k_getrusage(tsk, RUSAGE_BOTH, &info.si_rusage);
info.si_status = tsk->exit_code & 0x7f;
if (tsk->exit_code & 0x80)
......@@ -1558,7 +1557,6 @@ do_notify_parent_cldstop(struct task_struct *tsk, struct task_struct *parent,
/* FIXME: find out whether or not this is supposed to be c*time. */
info.si_utime = tsk->utime;
info.si_stime = tsk->stime;
k_getrusage(tsk, RUSAGE_BOTH, &info.si_rusage);
info.si_code = why;
switch (why) {
......@@ -2170,8 +2168,6 @@ int copy_siginfo_to_user(siginfo_t __user *to, siginfo_t *from)
err |= __put_user(from->si_status, &to->si_status);
err |= __put_user(from->si_utime, &to->si_utime);
err |= __put_user(from->si_stime, &to->si_stime);
err |= __copy_to_user(&to->si_rusage, &from->si_rusage,
sizeof(to->si_rusage));
break;
case __SI_RT: /* This is not generated by the kernel as of now. */
case __SI_MESGQ: /* But this is */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment