2/1/2023 0 Comments After the end fan fork![]() ![]() ![]() ![]() And indeed, the process spawning calls of competing operating systems typically fall somewhere in between.Īs for the waste of memory, it is avoided with the copy on write technique. Without fork(), the API for spawning processes would end up either extremely fat or not very useful. But the fork() design enables arbitrary manipulation of per-process resources in the child - one can close unwanted file descriptors, modify per-process limits, drop privileges, manipulate signal masks, and so on. Of course, for this simple case, there could be a spawning API that would simply do this automatically, given the proper parameters. Note how the redirection of standard output to the pipe is done in the child, between fork and exec. The canonical example is constructing a pipe: // read output of "ls"Ĭlose(pipe_fd) // we don't want to read from the pipeĭup2(pipe_fd, 1) // redirect stdout to the write end of the pipe The intermediate step enables you to set up shared resources in the child process without the external program being aware of it. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |