Sponsored Content
Top Forums Shell Programming and Scripting Need help with fork() on windows Post 302552302 by hansini on Friday 2nd of September 2011 09:47:17 AM
Old 09-02-2011
Need help with fork() on windows

Here is my sample perl program.
Code:
my $pid = fork();
if(! $pid )
{
      exec("perl sleep.pl 600");
} 
else
{
      print "PID ==== [$pid]\n";
      sleep 30;
      print "killing the PID [$pid] in 20 seconds\n";
      sleep 20;
      kill 9, $pid;
      print "Done ....\n"; 
}

The PID returns the pseudo process ID ( which is a negative number). When kill command sends 9 signal to the pseudo process ID, ( I assume the exec process ID falls under pseudo process ID) the exec process won't get killed.

Any help on how to kill the exec process on windows? I'm running this program on Windows XP.


Thanks In Advance
Hansini

Last edited by Franklin52; 09-02-2011 at 10:51 AM.. Reason: Please use code tags for code and data samples, thank you
 

5 More Discussions You Might Find Interesting

1. Programming

how to use function fork() in Windows NT

Hello, I need to make a gateway from Ethernet to RS-485. I am using stream socket, and I am programming in windows nt. I would like to know how could I use some functions from unix in windows nt. I would like to use the function fork(). Which library it uses and how can I get it? Can I... (1 Reply)
Discussion started by: danieljorge
1 Replies

2. Programming

Fork or what?

Hello all. I'm developing a filetransfer application, which is supposed to work sort of like dcc, with multiple transfers etc. Now i wonder what the best way to manage the transfers is. Should i fork() for each new transfer, hogging loads of memory or use pthreads? Maybe I can use select to see... (0 Replies)
Discussion started by: crippe
0 Replies

3. Programming

Fork and \n

Hi, I wrote a simple program for understanding the fork command. The code is as below int main(void) { fork(); printf("hi 1 \n"); fork(); printf("hi 2 \n"); fork(); printf("hi 3 \n"); } I am getting a variation in the number of times the printf is called if i remove the \n from each... (2 Replies)
Discussion started by: xyz123456
2 Replies

4. UNIX for Dummies Questions & Answers

fork()

I'm trying to run a simple test on how to use fork(), i'm able to execute the child process first then the parent, but how can I execute parent then child..? Thanks! (1 Reply)
Discussion started by: l flipboi l
1 Replies

5. Programming

Fork!

I understand that fork create a child but I need very simple example that make child useful.... I mean how will make the program faster anyone explain with code plz using C plz (2 Replies)
Discussion started by: fwrlfo
2 Replies
KILL(1) 						     Linux Programmer's Manual							   KILL(1)

NAME
kill - terminate a process SYNOPSIS
kill [ -s signal | -p ] [ -a ] [ -- ] pid ... kill -l [ signal ] DESCRIPTION
The command kill sends the specified signal to the specified process or process group. If no signal is specified, the TERM signal is sent. The TERM signal will kill processes which do not catch this signal. For other processes, it may be necessary to use the KILL (9) signal, since this signal cannot be caught. Most modern shells have a builtin kill function, with a usage rather similar to that of the command described here. The `-a' and `-p' options, and the possibility to specify pids by command name is a local extension. OPTIONS
pid... Specify the list of processes that kill should signal. Each pid can be one of five things: n where n is larger than 0. The process with pid n will be signaled. 0 All processes in the current process group are signaled. -1 All processes with pid larger than 1 will be signaled. -n where n is larger than 1. All processes in process group n are signaled. When an argument of the form `-n' is given, and it is meant to denote a process group, either the signal must be specified first, or the argument must be preceded by a `--' option, otherwise it will be taken as the signal to send. commandname All processes invoked using that name will be signaled. -s signal Specify the signal to send. The signal may be given as a signal name or number. -l Print a list of signal names. These are found in /usr/include/linux/signal.h -a Do not restrict the commandname-to-pid conversion to processes with the same uid as the present process. -p Specify that kill should only print the process id (pid) of the named processes, and not send any signals. SEE ALSO
bash(1), tcsh(1), kill(2), sigvec(2), signal(7) AUTHOR
Taken from BSD 4.4. The ability to translate process names to process ids was added by Salvatore Valente <svalente@mit.edu>. Linux Utilities 14 October 1994 KILL(1)
All times are GMT -4. The time now is 06:30 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy