lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


>  local p = assert(io.popen('aplaymidi -', 'w'))
>  p:write(my_midi)  -- fast; the MIDI is compact :-)
>  p:close()         -- waits several minutes :-(
>
> Is there a way of letting aplaymidi run on in the background?

Well, from my POV it's ok that close() waits, because the process is
still running and it needs it's stdout. Maybe doing the wait for
close() to return in a coroutine would help?

lg,
Martin


On 7 September 2010 13:41,  <pj@pjb.com.au> wrote:
> OK, one more on the subject:
>
>> > Problem is, popen
>> > doesn't give you the return value of the command you ran.
>> The good news is that closing the handle from io.popen in
>> Lua 5.2 does give you the return code.
>
> That it means p:close waits for the command to finish:
>
>  local p = assert(io.popen('aplaymidi -', 'w'))
>  p:write(my_midi)  -- fast; the MIDI is compact :-)
>  p:close()         -- waits several minutes :-(
>
> Is there a way of letting aplaymidi run on in the background?
>  p = io.popen('aplaymidi - &', 'w')
>  p:write(my_midi)
> fails with
>  - is not a Standard MIDI File   (it's empty :-( )
> and I get the same message from:
>  io.popen('sh -c "aplaymidi -" &', 'w')
>  p:write(my_midi)
> and likewise at the command-line:
>  cat t.mid | sh -c 'aplaymidi - &'
>
> Although at the command-line:
>  cat t.mid | sh -c "aplaymidi -" &
> works as intended, so by now I'm starting to get confused...
>
> Is there a right way to background the aplaymidi process ?
>
> Regards,  Peter Billam
>
> http://www.pjb.com.au       pj@pjb.com.au      (03) 6278 9410
> "Was der Meister nicht kann,   vermöcht es der Knabe, hätt er
>  ihm immer gehorcht?"   Siegfried to Mime, from Act 1 Scene 2
>
>
>