Dear All,
I am working IMX8 platform. I want start the script from kernel. I used system() function from stdlib.h in my code. But, I unable to achieve in kernel programming.
Is there any specified API to execute shells script from kernel driver ?
Is there any specified API to execute/start service from kernel driver ?
Thanks & Regards,
Vinoth S,
Hello vinothkumar,
This is not a good idea.
See the discussion on the link, please!
c - How to execute shell command in kernel programming? - Stack Overflow
Below contents are from : linux kernel中编程执行shell脚本? - 知乎
Original contects are written in Chinese, so I translate them into English:
-------------------------------------
1. Executing a shell script is the process of parsing and executing script files using a shell interpreter.
2. The shell interpreter itself is a process in user mode.
3. The system function essentially forks the shell interpreter process and executes the script file. So if you want to execute a shell script in the kernel mode, you need the kernel thread to implement the shell interpreter, read the script to the kernel through the file system, and call the shell kernel thread for execution. However, the running stack of the kernel thread is very small, and the kernel mode has many restrictions, and the execution of the script does not pay off.
--------------------------------------
Hope the information is helpful for you.
Have a nice day!
B.R,
Weidong
Thank you Weidong for the reply.
Vinoth S,