UNIX programming problems

Hi im a student,
1st time using unix, currently were writing programs using fork() and identifying differences between the parent child processes. Im finding getpid(), getppid(), retVal confusing and we are moving on to grps now any
sites or information you can supply me to make this alittle clearer would be greatly appreciated.

All processes in the UNIX-like environment are assigned process IDs. As I recall, all processes have a parent process ID except for the init process (but you will have to check me on that one). So, there is the 'super parent of all processes' and all subsequent processes are children, grandchildren, gg, ggg, gggg etc. of this process.

When you login, for example, your shell is a child of the process which created the shell. When you are in your shell, the all processes you create (C programs, utilities you run, command you run, etc.) all children of that shell.

Now, you have two main situations possible or questions to consider. When you kill a parent, do the children die? This behavior of the children depend on how the child processes were created. Variations of the <B>exec</B> command are used to create different situations. So, fork and exec are the two areas you need to study to understand process creation and destruction. This is not something you can understand in a quick summary in a class (unless you are very clever and grasp abstract concepts quickly.)

So, if the topic is of interest to you, do not feel constrained that the professor has moved on to further topics. The purpose of school is to point to you different areas; however, mastery of the subject is always based on individual interest and motivation. The best way to understand the relationship between process creation and destruction, parent-child relationship, is to write a simple C program with fork and exec; trying different things. However, <B>never do something like this: </B> while (1) { fork() }; :frowning: unless you are the owner of the platform and there are no other users. Malicious folks (not true gurus) learn quickly that it is possible to fork unlimited processes and flood the server (sometimes shutting it down). This is often controlled with ULIMIT for individual users. Regardless, this is considered very bad, malicious behavior.

Please, enjoy learning about computing, but always have consideration of other users and be aware of resource issues. Thanks :slight_smile: