I'm creating processes in loop with fork() function. The new processes do not call any function in the exec*()
family; they just run their code and then exit using exit()
. They can't fail.
But I don't know what to do if fork()
fails and I have already created some new processes. Do I have to use return or exit()
? Do I have to use killpg()
to kill created processes? If fork()
fails, I want to clean everything and exit program from main process. Can someone give me a hint how to do this?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.