ok a have the next code: - /* we use a fork to create a child process that sniffs the answers */
-
switch(pid = fork())
-
{
-
case -1:
-
pe("Error fork");
-
exit(1);
-
case 0:
-
sniffer(filter,nbr_pkt, 0, dev, resolve);
-
exit(1);
-
break;
-
default:
-
/* we wait to let the sniffer starts */
-
sleep(1);
-
/* we send our packets */
-
while (nbr_pkt > 0) {
-
if (ack_flag == 1)
-
send_tcp(srcaddr_r, htons(srcport), dstaddr_r, htons(dstport), th_seq, th_ack, 0, ttl, htons(ipid));
-
if (syn_flag == 1) {
-
th_ack = 0;
-
send_tcp(srcaddr_r, htons(srcport), dstaddr_r, htons(dstport), th_seq, th_ack, 1, ttl, htons(ipid));
-
}
-
--nbr_pkt;
-
}
-
/* we start a timer :after 3 seconds, a signal SIGALRM is emitted */
-
alarm(3);
-
/* we wait for any signal (SIGALRM from hprobe or SIGCHLD from the sniffer) */
-
pause();
-
}
-
exit(0);
-
}
what i am interested to knew is what is happened when the exit(1) executes in the child process, why the sniffer isn't stoping and it keeps running, from what i knew the exit() function shall exit from the program, but in this case it is something else, and i don't understand how that is done.
thx. and if you have any questions regarding any another aspect of the program that will help you explain me this statement i will gladly answer
2 4667
Could you please put your code in [code] brackets to make it more readable...Thanks
ok a have the next code: - /* we use a fork to create a child process that sniffs the answers */
-
switch(pid = fork())
-
{
-
case -1:
-
pe("Error fork");
-
exit(1);
-
case 0:
-
sniffer(filter,nbr_pkt, 0, dev, resolve);
-
exit(1);
-
break;
-
default:
-
/* we wait to let the sniffer starts */
-
sleep(1);
-
/* we send our packets */
-
while (nbr_pkt > 0) {
-
if (ack_flag == 1)
-
send_tcp(srcaddr_r, htons(srcport), dstaddr_r, htons(dstport), th_seq, th_ack, 0, ttl, htons(ipid));
-
if (syn_flag == 1) {
-
th_ack = 0;
-
send_tcp(srcaddr_r, htons(srcport), dstaddr_r, htons(dstport), th_seq, th_ack, 1, ttl, htons(ipid));
-
}
-
--nbr_pkt;
-
}
-
/* we start a timer :after 3 seconds, a signal SIGALRM is emitted */
-
alarm(3);
-
/* we wait for any signal (SIGALRM from hprobe or SIGCHLD from the sniffer) */
-
pause();
-
}
-
exit(0);
-
}
what i am interested to knew is what is happened when the exit(1) executes in the child process, why the sniffer isn't stoping and it keeps running, from what i knew the exit() function shall exit from the program, but in this case it is something else, and i don't understand how that is done.
thx. and if you have any questions regarding any another aspect of the program that will help you explain me this statement i will gladly answer
I understand now for what is the exit(1) function call, it will generate an SIGCHLD signal that will be caught later in the program with the signal() function.
Now i what to know what is the break instruction roll, and it will ever be executed, if will look that the exit(1) function is just above it?
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Benoit Dejean |
last post by:
hello, i have a question about forking processes
atm, i have some code which i want to rewrite
os.system("cd ~ && exec " + cmd + " & disown")
i want to remove this os.system call
|
by: steve |
last post by:
I was given the following code, and asked what the possible outputs
could be. We're learning about processes and forking.
int value;
int main(){
int pid, number = 1;
value = 2;
pid = fork();...
|
by: ramu |
last post by:
Hi All,
We know that a c function never returns more than one value.
Then how come the fork() function returns two values? How it is
implemented?
Regards
|
by: vduber6er |
last post by:
Hi I want to have a wait page while the rest of the cgi does its
process, but it seems like the wait page waits till everything is
complete and never appears. I've tried forking twice already as...
|
by: thrillseekersforever |
last post by:
The questions(A&B) are to fine no# of process running from the below
codes. However, I couldn't decipher the solution. Will someone please
throw some light on this? Thanks a lot!!
A]
void...
| |
by: JoeW |
last post by:
Now before I go into detail I just want to say that this is purely for
my own benefit and has no real world usage. I remember way back when
the tool for *nix systems called forkbomb was created. I...
|
by: CMorgan |
last post by:
Hi everybody,
I am experiencing an annoying problem with fork() and execv().
In my program I need to launch the "pppd" from a thread, so, I create
a new process with fork and then in the child...
|
by: Gilles Ganault |
last post by:
Hello
I need to launch a Python script, and fork it so that the calling
script can resume with the next step will the Python script keeps
running.
I tried those two, but they don't work, as...
|
by: Radz |
last post by:
when the fork system call is executed, a new process is created. The original process is called the parent process whereas the new process is called the child process. The new process consists of a...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |