Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > spawning a process

Reply
Thread Tools

spawning a process

 
 
Kurt M. Dresner
Guest
Posts: n/a
 
      08-16-2003
Hi,

I'm looking through the Ruby documentation and I'm trying to find an
equivalent to the Python: "pid = os.spawnv(os.P_NOWAIT, program, args)".

I want to play a sound file in a new process, but I want the ability to
terminate, stop, and continue this process from the file I am in.

Any suggestions?

-Kurt

 
Reply With Quote
 
 
 
 
Hal E. Fulton
Guest
Posts: n/a
 
      08-16-2003
----- Original Message -----
From: "Kurt M. Dresner" <(E-Mail Removed)>
To: "ruby-talk ML" <(E-Mail Removed)>
Sent: Saturday, August 16, 2003 1:12 PM
Subject: spawning a process


> Hi,
>
> I'm looking through the Ruby documentation and I'm trying to find an
> equivalent to the Python: "pid = os.spawnv(os.P_NOWAIT, program, args)".
>
> I want to play a sound file in a new process, but I want the ability to
> terminate, stop, and continue this process from the file I am in.
>
> Any suggestions?


I suppose that depends in part on what OS you're on
and how the sound player exposes its controls.

If you're on Linux or the equivalent, fork and pipe
will work. There's also exec and so on. Don't think
these work on Windows.

You might look into wrapping the sound player in a
drb server that you can then invoke from anywhere.

Hal

--
Hal Fulton
http://www.velocityreviews.com/forums/(E-Mail Removed)



 
Reply With Quote
 
 
 
 
Kurt M. Dresner
Guest
Posts: n/a
 
      08-16-2003
I'm using Debian GNU/Linux, and I want to use mpg123 and ogg123.

-Kurt

On Sun, Aug 17, 2003 at 03:17:50AM +0900, Hal E. Fulton wrote:
> ----- Original Message -----
> From: "Kurt M. Dresner" <(E-Mail Removed)>
> To: "ruby-talk ML" <(E-Mail Removed)>
> Sent: Saturday, August 16, 2003 1:12 PM
> Subject: spawning a process
>
>
> > Hi,
> >
> > I'm looking through the Ruby documentation and I'm trying to find an
> > equivalent to the Python: "pid = os.spawnv(os.P_NOWAIT, program, args)".
> >
> > I want to play a sound file in a new process, but I want the ability to
> > terminate, stop, and continue this process from the file I am in.
> >
> > Any suggestions?

>
> I suppose that depends in part on what OS you're on
> and how the sound player exposes its controls.
>
> If you're on Linux or the equivalent, fork and pipe
> will work. There's also exec and so on. Don't think
> these work on Windows.
>
> You might look into wrapping the sound player in a
> drb server that you can then invoke from anywhere.
>
> Hal
>
> --
> Hal Fulton
> (E-Mail Removed)
>
>
>
>======= End of Original Message =======<


 
Reply With Quote
 
Armin Roehrl
Guest
Posts: n/a
 
      08-16-2003

> I suppose that depends in part on what OS you're on
> and how the sound player exposes its controls.
>
> If you're on Linux or the equivalent, fork and pipe
> will work. There's also exec and so on. Don't think these work on
> Windows.
>

Alternatively, if stuck on Windows, experiment with non-MS-compiled
ruby-versions: cygwin, djgpp, ..
http://ftp.ruby-lang.org/pub/ruby/binaries/

I know too little about the Windows-world to tell you which
works with what implemenation, but I once got read of a nasty
socket problem in ruby .. simply by switching to the cygwin version.

 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      08-16-2003
On Sun, Aug 17, 2003 at 03:12:24AM +0900, Kurt M. Dresner wrote:
> I'm looking through the Ruby documentation and I'm trying to find an
> equivalent to the Python: "pid = os.spawnv(os.P_NOWAIT, program, args)".
>
> I want to play a sound file in a new process, but I want the ability to
> terminate, stop, and continue this process from the file I am in.
>
> Any suggestions?


pid = fork {
exec(program,*args)
}

then you can send signals to that particular pid.

Alternatively, if your command is controlled by messages sent on its stdin,
then:

cmd = IO.popen("program args","w")
cmd.puts "play" # or whatever

Regards,

Brian.

 
Reply With Quote
 
Brian Candler
Guest
Posts: n/a
 
      08-16-2003
On Sun, Aug 17, 2003 at 03:48:39AM +0900, Brian Candler wrote:
> > Any suggestions?

>
> pid = fork {
> exec(program,*args)
> }


Oh, beware that the child will share stdin / stdout / stderr with your main
process. If you don't want that, you can reopen them:

pid = fork {
STDIN.reopen('/dev/null')
# ditto for STDOUT and/or STDERR if you wish
exec(program,*args)
}

Regards,

Brian.

 
Reply With Quote
 
Eric Hodel
Guest
Posts: n/a
 
      08-18-2003

--gXx2FYK2AghGE4Yq
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

Kurt M. Dresner ((E-Mail Removed)) wrote:

> I want to play a sound file in a new process, but I want the ability to
> terminate, stop, and continue this process from the file I am in.
>=20
> Any suggestions?


Take a look at rmp3 in raa:

http://raa.ruby-lang.org/list.rhtml?name=3Drmp3

It allows you to play/stop, etc mpg123/321, and is pretty easy to follow
(I hijacked it for Webplayer, also in the RAA). Even if you're not
using mp3 files, it may be worth a look.

--=20
Eric Hodel - (E-Mail Removed) - http://segment7.net
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04


--gXx2FYK2AghGE4Yq
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQE/QQnOMypVHHlsnwQRAhtfAJ4sH/Dn+dsZOepwm1Eo82Kk3iQo0ACgzcPi
4aSWtmn2/eiDT5LAbUs2CHw=
=rF51
-----END PGP SIGNATURE-----

--gXx2FYK2AghGE4Yq--

 
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
Spawning process from Java gives deadlock for standard output peter.koch.larsen@gmail.com Java 8 05-24-2006 08:36 PM
spawning a process from webform1 Ashish ASP .Net 0 07-11-2005 10:37 PM
Spawning a process with ASP.NET 2.0 beta 2 Marianne ASP .Net 4 07-07-2005 11:09 AM
Error Spawning Process from ASP.NET hoochiegooch@hotmail.com ASP .Net 4 02-08-2005 04:37 PM
Process spawning in win32 Uri Nix Python 0 08-22-2004 10:51 AM



Advertisments