lkml.org 
[lkml]   [2012]   [Mar]   [23]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [RFC 4/4] {RFC} kmod.c: Add new call_usermodehelper_timeout()API
On 03/22, Boaz Harrosh wrote:
>
> On 03/22/2012 03:16 PM, Tetsuo Handa wrote:
>
> > I think you should use a fork()ed wrapper in userspace for implementing
> > timeout.
>
> I did that actually. But I would like not to be dependent on it. I would like
> the Kernel to be independent and simple timeout and recover,

Tetsuo, Boaz, since I do not understand the problem space, I am not
going to discuss the "do we need the timeout" thing.

But, just in case, perhaps there is no need to change kmod.c ? I do
not know if it works for you, but you can simply do something like


struct kill_work {
struct delayed_work work;
struct pid *pid;
};

void kill_work_func(struct work_struct *_work)
{
struct kill_work *work = container_of(_work, struct kill_work, work);
kill_pid(work->pid, SIGKILL);
put_pid(work->pid);
kfree(work);
}

int unh_setup_timeout(struct subprocess_info *info, struct cred *new)
{
struct kill_work *work = kmalloc(sizeof(struct kill_work));
if (!work)
return -ENOMEM;

INIT_WORK(&work->work, kill_work_func);
work->pid = get_pid(task_pid(current));
schedule_delayed_work(&work->work, (long)info->data);

return 0;
}

Now you can do

call_usermodehelper_fns(init => unh_setup_timeout,
data => (void*)timeout);

Oleg.



\
 
 \ /
  Last update: 2012-03-23 17:41    [W:0.070 / U:1.876 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site