[LA.pm] does system() wait?

Jeremy Leader jleader at alumni.caltech.edu
Mon Feb 21 21:03:07 PST 2005


cch2cch at netscape.net wrote:
> Hi,
> 
> I  am running activePerl 5.6 on win98se. When I run these statements:
> 
> system("...realplayer  song1.mp3");
> system("...realplayer  song2.mp3");
> system("...realplayer song3.mp3");
> 
> I expect the three songs to be played in sequence. Instead only song3 is
> played. It seems all three system() function are executed but one
> overrides the other. I  believe Perl waits for system() to  finish  
> before continuing. Is it not so in the PC environment? Thanks

Yes, system does a fork, exec, wait (or some rough equivalent).

However, I don't know what the semantics of calling "...realplayer" are.
Some programs perform an action, and don't exit/return to the caller
until the action is done.  Other programs are just interfaces to some
daemon process, and will exit/return as soon as they've relayed the
appropriate command to the daemon process.  My guess is that realplayer
does the latter, so each invocation to "...realplayer" just sends a
command to the realplayer daemon to tell it to start a new song.

There might be an option to "...realplayer" to tell it to wait until
the song finishes before returning, I don't know.  Or, there might
be some interface you could call which would tell you the currently
playing song, and your script would have to loop, checking which song
is playing and sleeping until it's time to start the next song.

-- 
Jeremy Leader
jleader at alumni.caltech.edu



More information about the Losangeles-pm mailing list