0

I use call_usermodehelper to open qt why I can't open? How to solve this problem? Or other way use kernel to open user-space application?

#include <linux/init.h>
#include <linux/module.h>
#include <linux/kmod.h>
MODULE_LICENSE("GPL");
static int umh_test( void ) {
    char *argv[] = { "/usr/bin/qtcreator", NULL };
    static char *envp[] = {
        "HOME=/",
        "TERM=linux",
        "PATH=/sbin:/bin:/usr/sbin:/usr/bin",
        NULL
    };
    return call_usermodehelper( argv[0], argv, envp, UMH_WAIT_PROC);
}
static int hello_init(void)
{
    int ret = 0;
    ret = umh_test();
    printk(KERN_INFO "retval11: %d\n", ret);
    return 0;
}

static void hello_exit(void)
{
    printk(KERN_INFO "BYE\n");
}

module_init(hello_init);
module_exit(hello_exit);

Picture showing the error picture: Error picture

kayess
  • 3,384
  • 9
  • 28
  • 45
  • Kernel function `call_usermodehelper` uses exactly that evironment which you give in `envp` argument, it doesn't call additional startup scripts. From the other side, GTK programs need more than 2 environment variable set. It is not recommended to launch GUI applications from this special *kernel* function. – Tsyvarev Mar 23 '16 at 20:09
  • Thank you I can open gui app. – 呂孟穎 Mar 30 '16 at 06:21

0 Answers0