theKbStockpiler
theKbStockpiler

Reputation: 1

What are the Ways and Methods in Which Linux Launches Applications

I'm interested in what goes on in-between clicking on an icon and having init create a new process. I know that bash can launch an application as it's child but does Bash just issue a fork command? Does X Windows System do the same? Does the Gnome panel launchers just forward the application name to BASH? What gets the informantion of the "Command line that started the process"?

Upvotes: 0

Views: 60

Answers (1)

salezica
salezica

Reputation: 76949

In Linux, you create new processes with fork(), so everyone interested in spawning processes walks down that road.

BASH uses fork(), and then some other system calls (I'd guess along the lines of dup2(), pipe(), etc.) to handle the input and output configuration for the new process. It takes care of passing parameters and environmental variables, as well. Then, a final exec() hands the execution over to the second program.

You don't need, however, to use BASH to spawn processes. Any processes can fork() and exec(): you can create a program launcher yourself in less than 15 lines of C code.

Upvotes: 2

Related Questions