call_usermodehelper()中的UMH_NO_WAIT是否正常工作?

我怀疑call_usermodehelper()中的UMH_NO_WAIT选项是否正常工作,或者我遗漏了什么。

这是参考以下线程, 内核模块定期调用用户空间程序

#include  /* Needed by all modules */ #include  /* Needed for KERN_INFO */ #include  /* Needed for the macros */ #include  #include  #include  #include  #include  #include  #include  #define TIME_PERIOD 5000000000 static struct hrtimer hr_timer; static ktime_t ktime_period_ns; static enum hrtimer_restart timer_callback(struct hrtimer *timer){ char userprog[] = "test.sh"; char *argv[] = {userprog, "2", NULL }; char *envp[] = {"HOME=/", "PATH=/sbin:/usr/sbin:/bin:/usr/bin", NULL }; printk("\n Timer is running"); hrtimer_forward_now(&hr_timer, ktime_period_ns); printk("callmodule: %s\n", userprog); call_usermodehelper(userprog, argv, envp, UMH_NO_WAIT); return HRTIMER_RESTART; } static int __init timer_init() { ktime_period_ns= ktime_set( 0, TIME_PERIOD); hrtimer_init ( &hr_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL ); hr_timer.function = timer_callback; hrtimer_start( &hr_timer, ktime_period_ns, HRTIMER_MODE_REL ); return 0; } static int __exit timer_exit(){ int cancelled = hrtimer_cancel(&hr_timer); if (cancelled) printk(KERN_ERR "Timer is still running\n"); else printk(KERN_ERR "Timer is cancelled\n"); } module_init(timer_init); module_exit(timer_exit); MODULE_LICENSE("GPL"); 

我认为由于call_usermodehelper()调用,系统挂起。因为,在call_usermodehelper()函数调用时,只有系统冻结。 因此,我尝试使用选项UMH_NO_WAIT,以便内核代码不会等待用户进程执行。然后系统挂起。请检查www.kernel.org/doc/htmldocs/kernel-api/API-call -usermodehelper.html