how to kill a port's external process?

per@REDACTED per@REDACTED
Thu Jul 26 12:18:52 CEST 2001


Chris Pressey <cpressey@REDACTED> wrote:
>
>"Garrett G. Hodgson" wrote:
>> i'm building a little gui wrapper around a command line audio player.
>> i've got an erlang process that calls open_port() to spawn the external
>> player, but it doesn't actually send/receive anything to it over stdio.
>
>I don't think the port mechanism was ever intended to be used that way
>:)

True.:-) Well, at least if you intended to control the external program
in *any* way - e.g. firing up an independent daemon or whatever with
os:cmd() (that uses the port mechanim of course) is a reasonable thing
to do.

>Do you have the source to the external program?  It might help to
>rewrite the main body to listen to the Erlang ports mechanism, even if
>there's no established interface.

Actually, it could be done with a "wrapper", perhaps even something as
simple as:

  #!/bin/sh
  program &
  pid=$!
  while read dummy; do :; done
  kill $pid
  exit 0

But of course one has to wonder what the Erlang-based GUI is for if it
can't communicate with the program...:-)

--Per Hedeland
per@REDACTED



More information about the erlang-questions mailing list