Problem with creating linux embedded child process

I am using linux kernel 2.6.30 on my board. It has 128 MB DDR2. My main application takes up almost 80 MB of system memory. After running all the applications, only 25 MB is left. I want to execute system commands from my main application (which uses 80 MB). But it is not fulfilled. In my understanding, each child process requires the same memory as the parent process (I got this description from the fork function manual). Therefore, in my case, the new child process requires another 80 MB, which is not available. Therefore, the system call does not work. The system command should be executed immediately after issuing the command, since the following steps in the main application require the result of the system command (for example, you need to save the output of the grep command in a file and immediately read this file for further processing).Therefore, I cannot use the IPC mechanism. What are other ways?

Saurabh Shah

+3
source share
4 answers

Unless you have some kind of fancy, crippled processor architecture or libc, it should use Copy-on-Write with fork(), so you should be good with exec().

+1
source

If you use system(), then you will need to execute a shell to parse and execute your command, and the shell can be large. If you can split the line into a command and arguments yourself, you can call fork()and execve()so that the shell does not need to be loaded.

+1
source

glib, .

: http://library.gnome.org/devel/glib/2.22/glib-Spawning-Processes.html

g_spawn_sync, , , .

, system() . , fork() exec() ( ), , , fork() exec() else), .

, .

0

, . , , thttpd . strace.
, , , .

, , IPC . , . , unix .

0

Source: https://habr.com/ru/post/1732298/


All Articles