0

I run this bash function when a button is pressed, it calls my mobile, however when the call ends or I reject the call, it hangs in /dev/tty and does not return to the main program

call.sh

#!/bin/bash

printf %s\\n 'call sip:[email protected]' | cat - /dev/tty |twinkle -c

Here is the main program:

while(1):
if lcd.buttonPressed(lcd.SELECT):
   os.system("./call.sh")

When phone is offline or call is rejected, it hangs and does not return back to the python program: enter image description here

I would then have to press CTRL + C and CTRL + Z to exit which closes the python program too.

enter image description here

Is it possible to return back to the main program after a 408 Request timeout error or a 468 Busy Here message?

enter image description here

EDIT: The answer was mkfifo /tmp/pipe; exec 3<>/tmp/pipe; (trap '' TTIN TTOU; twinkle -c) <&3 & printf '\ncall sip:'[email protected] >&3 thanks to @mikeserv

23
  • You probably want to try CTRL-D at the start of a line. Still, I told you it was a hack.
    – mikeserv
    Feb 8, 2015 at 21:45
  • How would that work if there needs to be a check if a 408 request timeout error occurred or a 468 Busy Here message. Also CTRL +D gives the same thing as CTRL +C
    – Hamoudy
    Feb 8, 2015 at 21:48
  • It could be more of a hack, though - you could insert a head or something between the cat and twinkle and add /proc/self/stat to the list of cat's files like cat /proc/self/stat - /dev/tty - that would write a bunch of information about the cat process that you could capture and use to shut it down later - the first few bytes are the pid.
    – mikeserv
    Feb 8, 2015 at 21:49
  • It's your python program, man. You need to ignore the signal.
    – mikeserv
    Feb 8, 2015 at 21:51
  • Tried the /proc/self/stat and this is what I got prntscr.com/62r93w
    – Hamoudy
    Feb 8, 2015 at 21:53

1 Answer 1

1

If you want twinkle to place a call when you press your button, I would suggest that you get your key-monitoring program to use twinkle's command line to do that directly:

twinkle -c --immediate --call sip:[email protected]

It would be far easier that all this fiddling around with ttys, etc.

Or have I misunderstood your intent?

1
  • it is just a gpio button which I have programmed to do other functions too such as send an email.
    – Hamoudy
    Feb 8, 2015 at 22:46

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .