stdout - fork() and printf() -


As I've understood a forek () the copy of the image of the original process has created a hair process.

My question is how does the child and parent process share the stdout stream?

Could the printf () function of a process be interrupted by another?

For example:

The first case:

or the printf () function is atomic?

Example:

The first case:

ex> guardian: printf ("hello"); Kids: printf ("world \ n"); In the console: HeWollorld

The second case:

  Guardian: printf ("hello"); Kids: printf ("world \ n"); In the console: "Hello World"  

printf () Not guaranteed to be nuclear If you need atom, use

() preformatted using a string, using s * printf () etc., if Be necessary. Regardless of this, you should make the size of the written data using write :

Writing on a single pipe will not be handwritten with the data from other processes. With written by other processes in written by more than {PIPE_BUF} , data interlave may be possible on arbitrary boundaries, even if the file status flag set the O_NONBLOCK flag Got it


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -