Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: exec function does not return command prompt

by Crackers2 (Parson)
on Aug 16, 2014 at 01:05 UTC ( #1097633=note: print w/replies, xml ) Need Help??


in reply to exec function does not return command prompt

When I execute the parent script I receive the following output:
/liwidata/dev/tmp/jmg/dev/library> ./test1.pl In test1 the parent pid is 21348; the child pid is 21349 All done! /liwidata/dev/tmp/jmg/dev/library> In test2.pl the pid is 21349
As you can see the command prompt does not appear at the conclusion of the child script.

Are you sure? To me it looks like the prompt is right there, _before_ the "In test2.pl" output.

Instead of Ctrl-C, have you tried just entering a command? (or pressing enter to simply go to the next line)

Replies are listed 'Best First'.
Re^2: exec function does not return command prompt
by casman46 (Initiate) on Aug 18, 2014 at 12:42 UTC

    Crackers2: Thank you for your reply to my question. It appears that I do not understand how the fork function works. Nevertheless, since both test1.pl and test2.pl do exit, shouldn't I see a command prompt at the conclusion of each one?

      No. That's not how the shell works. Either it will wait for both to exit before showing the (one) prompt, or it will show the prompt after a certain proces exits and finish the other one in the background; in that case you won't get a new prompt after the background one exits.

      I'm not exactly sure when it decides to keep stuff in the foreground or run them in the background.

      In your case I think it's running both in the foreground, but due to buffering the output from test2 just happens to show up after the prompt

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1097633]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (6)
As of 2020-10-23 10:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My favourite web site is:












    Results (237 votes). Check out past polls.

    Notices?