Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > fork command.

Reply
Thread Tools

fork command.

 
 
rajendra
Guest
Posts: n/a
 
      07-26-2007
Hello All,
The perl documentation says the fork command generates two copies of the
program ,one parent and one child.
If this is correct,can this fork command be used for multitasking?.



 
Reply With Quote
 
 
 
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      07-26-2007
rajendra <> wrote in comp.lang.perl.misc:
> Hello All,
> The perl documentation says the fork command generates two copies of the
> program ,one parent and one child.
> If this is correct,can this fork command be used for multitasking?.


Yes, that is its very purpose.

Anno
 
Reply With Quote
 
 
 
 
Michele Dondi
Guest
Posts: n/a
 
      07-26-2007
On Thu, 26 Jul 2007 15:43:24 +0530, "rajendra"
<> wrote:

>The perl documentation says the fork command generates two copies of the
>program ,one parent and one child.
>If this is correct,can this fork command be used for multitasking?.


Well, yes: but what do you mean exactly? AIUI multitasking is better
seen as a property of "some" osen and fork() is one way to use it to
one's advantage...


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
Reply With Quote
 
Jürgen Exner
Guest
Posts: n/a
 
      07-26-2007
rajendra wrote:
> The perl documentation says the fork command generates two copies of
> the program ,one parent and one child.


Well, no. It creates _one_ additional copy of the running process, commonly
known as child process.

> If this is correct,can this fork command be used for multitasking?.


That is its main purpose, yes.

jue


 
Reply With Quote
 
Ted Zlatanov
Guest
Posts: n/a
 
      07-26-2007
On 26 Jul 2007 11:29:14 GMT wrote:

a> rajendra <> wrote in comp.lang.perl.misc:
>> The perl documentation says the fork command generates two copies of the
>> program ,one parent and one child.
>> If this is correct,can this fork command be used for multitasking?.


a> Yes, that is its very purpose.

I usually point people to the Stevens books (Advanced Programming in the
Unix Environment 2nd ed., especially) or some equivalent tutorial,
whenever they ask about fork(). I think using fork() requires
understanding the way it works on the OS level--at least IPC and IO
stream behavior, if nothing else.

Ted
 
Reply With Quote
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      07-27-2007
Ted Zlatanov <> wrote in comp.lang.perl.misc:
> On 26 Jul 2007 11:29:14 GMT wrote:
>
> a> rajendra <> wrote in comp.lang.perl.misc:
> >> The perl documentation says the fork command generates two copies of the
> >> program ,one parent and one child.
> >> If this is correct,can this fork command be used for multitasking?.

>
> a> Yes, that is its very purpose.
>
> I usually point people to the Stevens books (Advanced Programming in the
> Unix Environment 2nd ed., especially) or some equivalent tutorial,


Just for the record, _Advanced Programming in the Unix Environment_
itself is *not* a tutorial but a hard-core reference.

Anno
 
Reply With Quote
 
rajendra
Guest
Posts: n/a
 
      07-30-2007
One more query:
Can I use a variable common to both child and parent process block?.
"rajendra" <> wrote in message
news:f89s46$i07$...
> Hello All,
> The perl documentation says the fork command generates two copies of the
> program ,one parent and one child.
> If this is correct,can this fork command be used for multitasking?.
>
>
>



 
Reply With Quote
 
anno4000@radom.zrz.tu-berlin.de
Guest
Posts: n/a
 
      07-30-2007
rajendra <> wrote in comp.lang.perl.misc:
> One more query:
> Can I use a variable common to both child and parent process block?.


You can. Note that the same name addresses different variables in
the parent and the child. They will have the same initial value in
both, but changes in one don't reflect in the other.

Anno
 
Reply With Quote
 
rajendra
Guest
Posts: n/a
 
      07-30-2007

If i want to update(modify) a in both child and parent process, how can I do
this?....
<> wrote in message
news:...
> rajendra <> wrote in comp.lang.perl.misc:
> > One more query:
> > Can I use a variable common to both child and parent process block?.

>
> You can. Note that the same name addresses different variables in
> the parent and the child. They will have the same initial value in
> both, but changes in one don't reflect in the other.
>
> Anno



 
Reply With Quote
 
Michele Dondi
Guest
Posts: n/a
 
      07-30-2007
On Mon, 30 Jul 2007 17:12:06 +0530, "rajendra"
<> wrote:

>If i want to update(modify) a in both child and parent process, how can I do
>this?....


You must establys some sort of IPC between them. Read

perldoc perlipc

to find out some ways to do so.


Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
..'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
os.fork and pty.fork Eric Snow Python 0 01-08-2009 06:32 AM
Noob help request on TCP Server with fork xchris Perl 5 06-22-2004 11:56 AM
Can't fork exec from webpage, problem is not permissions Patrick Perl 1 05-14-2004 12:03 PM
fork in perl 5.8.3 on windows Josh Denny Perl 2 03-02-2004 11:24 PM
fork CwK Perl 2 01-04-2004 04:13 PM



Advertisments