Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
523 views
in Technique[技术] by (71.8m points)

c - How does system() exactly work in linux?

I've been reading its man page but haven't yet been successful in figuring out how it works. On calling system(), is a new child process forked and the shell binary exec()-ed in it? That may be a stupid guess though.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Yes, system() is essentially a fork() and exec() "sh -c" for the passed command string. An example implementation (from eglibc, recently forked from glibc) can be found here.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...