What are the differences between and in C programming 1 fi
What are the differences between ........... and ........... in C programming?
1/ filename and file pointer
2/ fan and chain
Solution
A file descriptor is a low-level integer \"handle\" used to identify an opened file (or socket, or whatever) at the kernel level, in Linux and other Unix-like systems.
A FILE pointer is a C standard library-level construct, used to represent a file. The FILE wraps the file descriptor, and adds buffering and other features to make I/O easier.
chidlpid = fork() \" clones the current process with the parent (original) receiving a non-zero value and the child (clone) receiving 0. If the clone could not be created, a negative value is returned
Fan: if ((childpid = fork()) <= 0) break; \" says
1. If I\'m the child ( childpid == 0) or if cloning failed ( childpid < 0), get out of the cloning business.
2. Otherwise, keep making clones FROM THE PARENT.
... so you get one parent, and many children one generation deep
Chain: if ((childpid = fork()) != 0) break; \" then
1. If I\'m NOT the child ( childpid != 0), get out of the cloning business.
2. Otherwise, I\'m the child process and must continue the loop where my parent left off and keep making copies.
... so you get a chain. Parent makes 1\'st child who makes 2\'nd child, etc.
