Sponsored Content
Full Discussion: UNIX programming problems
Top Forums UNIX for Dummies Questions & Answers UNIX programming problems Post 1296 by Neo on Thursday 22nd of February 2001 12:55:35 PM
Old 02-22-2001
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() }; Smilie 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 Smilie
 

9 More Discussions You Might Find Interesting

1. IP Networking

TCP Programming problems with 'recv'

Hey, I am learning to program a TCP server and managed to get it up and running (I am using Windows 98SE). I can use the send function to send information to the client and I can use the recv function to ask the user to pass information through, but when I do so it only allows the client to... (1 Reply)
Discussion started by: KrazyGuyPaul
1 Replies

2. Programming

c programming or unix programming!?

i would like advice on the usbject of c programming (in the middle of reading a book on C). could i benefit more if i apply that knowledge in the unix format if i were able to, or would that take the point out of learning C, basically I want to stay away from strying too far away from unix and use... (1 Reply)
Discussion started by: moxxx68
1 Replies

3. UNIX for Dummies Questions & Answers

new to unix programming

hi guys, I m from india. I m working as programmer in one of MNC. Since 3 years im working on Microsoft platform on dot net and platforms. but now i decided to shift my future to unix , Linux side. I want to be the part of this open source family. and with this i want to make my future also.... (6 Replies)
Discussion started by: d_swapneel14
6 Replies

4. Shell Programming and Scripting

Unix Systems Programming Vs Unix Programming

Several months ago I found a link that explained the difference between how a Unix Systems Admin would do scripting compared to what a Unix Programmer would do. It showed a basic script and then show several iterations that explained how the Systems Admin would change it to make it better. I was... (0 Replies)
Discussion started by: BCarlson
0 Replies

5. UNIX for Dummies Questions & Answers

Carreer:Networking Programming in Unix (C programming Language)

Hello, I am trying to learn Networking Programming in C in unix enviorment. I want to know how good it is to become a network programmer. i am crazy about Network programming but i also want to opt for the best carreer options. Anybody experienced Network Programmer, please tell me is my... (5 Replies)
Discussion started by: vibhory2j
5 Replies

6. Programming

Please help! accept function problems in Socket programming

Hi, I have a client-server socket program. It has been working fine for over a year, but recently it started to show strange behavior.:confused: After the server program runs for a while, it will show in the top command saying it is using lots of CPU, MEM. I assume it means the server code is... (1 Reply)
Discussion started by: natxie
1 Replies

7. Shell Programming and Scripting

Unix programming help

hey guys im trying to create a batch file that makes directories i have this code atm #!/bin/sh echo "Please enter file name:" read Filename echo "enter number of files to be created " read created for (( i = 1; i < &created; 1++ )) do mkdir $Filename$i done assume i enter... (7 Replies)
Discussion started by: josh111
7 Replies

8. UNIX for Dummies Questions & Answers

How does unix system administration, unix programming, unix network programming differ?

How does unix system administration, unix programming, unix network programming differ? Please help. (0 Replies)
Discussion started by: thulasidharan2k
0 Replies

9. Programming

Looping problems socket programming in C

Sorry if I posted 2 separate questions. I'm currently doing socket programming on my current task. As you can see below in the client side. I've tried to do a loop so I will be able to get prompt for input over and over again. This is the code. do{ printf("Please your name > ");... (10 Replies)
Discussion started by: aLHaNz
10 Replies
getpid(2)							System Calls Manual							 getpid(2)

NAME
getpid, getpgrp, getppid - Gets the process ID, process group ID, parent process ID SYNOPSIS
#include <unistd.h> pid_t getpid( void ); pid_t getpgrp( void ); pid_t getppid( void ); Application developers may want to specify an #include statement for <sys/types.h> before the one for <unistd.h> if programs are being developed for multiple platforms. The additional #include statement is not required on Tru64 UNIX systems or by ISO or X/Open standards, but may be required on other vendors' systems that conform to these standards. STANDARDS
Interfaces documented on this reference page conform to industry standards as follows: getpid(), getpgrp(), getppid(): POSIX.1, XPG4, XPG4-UNIX Refer to the standards(5) reference page for more information about industry standards and associated tags. DESCRIPTION
The getpid() function returns the process ID of the calling process. The getpgrp() function returns the process group ID of the calling process. The getppid() function returns the parent process ID of the calling process. When a process is created, its parent process ID is the process ID of its parent process. If a parent process exits, the parent process IDs of its child processes are changed to the process ID of the init program. RELATED INFORMATION
System calls: fork(2), kill(2), setpgid(2), setsid(2), wait(2) Standards: standards(5) delim off getpid(2)
All times are GMT -4. The time now is 09:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy