Jump to content

system() on linux?

Go to solution Solved by trag1c,

Same reason as windows System() executes another executable which can be replaced by anyone. It's also fairly heavy on resources.

 

Consider CreateProcess() on windows and fork() and exec() on linux for starting applications. Since these create new processes they're independent from the master process and are subject to their own privileges.

 

E.g. main process is administrator access the secondary is only user access if configured that way. System would make both processes with admin rights which is extremely bad if another program hijacked the executable of the second process.

Hi, so I'm primarily a javascript dev however I do know some C++ and I'm trying to write a launcher for a game I'm developing

 

 

I understand that on windows using system() is bad practice for security reasons, however i'm developing for linux and I'm seeing a lot of people recommending system and popen for this OS.

Are there any reasons I shouldn't be using these two commands?

My procrastination is the bane of my existence.

I make games and stuff in my spare time.

 

 

Link to comment
https://linustechtips.com/topic/955285-system-on-linux/
Share on other sites

Link to post
Share on other sites

Same reason as windows System() executes another executable which can be replaced by anyone. It's also fairly heavy on resources.

 

Consider CreateProcess() on windows and fork() and exec() on linux for starting applications. Since these create new processes they're independent from the master process and are subject to their own privileges.

 

E.g. main process is administrator access the secondary is only user access if configured that way. System would make both processes with admin rights which is extremely bad if another program hijacked the executable of the second process.

CPU: Intel i7 - 5820k @ 4.5GHz, Cooler: Corsair H80i, Motherboard: MSI X99S Gaming 7, RAM: Corsair Vengeance LPX 32GB DDR4 2666MHz CL16,

GPU: ASUS GTX 980 Strix, Case: Corsair 900D, PSU: Corsair AX860i 860W, Keyboard: Logitech G19, Mouse: Corsair M95, Storage: Intel 730 Series 480GB SSD, WD 1.5TB Black

Display: BenQ XL2730Z 2560x1440 144Hz

Link to comment
https://linustechtips.com/topic/955285-system-on-linux/#findComment-11603356
Share on other sites

Link to post
Share on other sites

11 minutes ago, trag1c said:

Same reason as windows System() executes another executable which can be replaced by anyone. It's also fairly heavy on resources.

 

Consider CreateProcess() on windows and fork() and exec() on linux for starting applications. Since these create new processes they're independent from the master process and are subject to their own privileges.

 

E.g. main process is administrator access the secondary is only user access if configured that way. System would make both processes with admin rights which is extremely bad if another program hijacked the executable of the second process.

Thanks for the response! This was very helpful

My procrastination is the bane of my existence.

I make games and stuff in my spare time.

 

 

Link to comment
https://linustechtips.com/topic/955285-system-on-linux/#findComment-11603380
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×