News for hackers. Stuff that matters.
Re:Taming non-terminating Bash processes by pstadler on Saturday November 08, 2014 @05:12PM (#8578301)
Results from dns-sd are not necessarily being delivered instantly and there might be no lines which contain this flag to check of it's the last entry. It's also rather ugly to create a named pipe for this purpose, don't you think?
Re:Taming non-terminating Bash processes by fensipens on Saturday November 08, 2014 @06:06PM (#8578439)
there might be no lines which contain this flag

Again, untested:

        #! /bin/sh

        timeout=5
        fifo=/tmp/discover-vnc.fifo
        rm -f $fifo
        mkfifo $fifo

        dns-sd -B _rfb._tcp >$fifo &
        pid1=$!

        while read line; do
          case $line in *_rfb._tcp.*)
            # do something here.. then test
            # if flag=3 and break otherwise
          esac
        done <$fifo &
        pid2=$!

        sleep $timeout && kill $pid1 $pid2 &
        pid3=$!

        wait $pid2
        kill $pid3
It's also rather ugly to create a named pipe for this purpose

Because it creates a file in /tmp? Who cares? The alternative is bash voodoo magic.. the same magic that gave us shellshock.

Re:Taming non-terminating Bash processes by pstadler on Saturday November 08, 2014 @07:05PM (#8578592)
The alternative is bash voodoo magic.. the same magic that gave us shellshock.

I love this one.