API to start script in kernel programming

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

API to start script in kernel programming

987 次查看
vinothkumars
Senior Contributor IV

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,

Regards,
Vinothkumar Sekar
0 项奖励
回复
2 回复数

938 次查看
weidong_sun
NXP TechSupport
NXP TechSupport

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

0 项奖励
回复

938 次查看
vinothkumars
Senior Contributor IV

Thank you Weidong for the reply.

Vinoth S,

Regards,
Vinothkumar Sekar
0 项奖励
回复