sub fifocmd { my ($output_window, $input_window, $status_line, $connection) = @_; my ($fifodata, $rin, $rout); if (mkfifo($icbmfifo, oct('0600'))) { icb_debug ($output_window, 1, "fifocmd() opening command FIFO %s", $icbmfifo); # We have to use sysopen() here rather than 'open (FIFO, $icbmfifo);' # because on many preinstalled Perls, open() does NOT use O_NONBLOCK. # This causes breakage, as in the open() call never returns until and # unless something writes to the other end of the pipe. sysopen (FIFO, $icbmfifo, O_RDONLY|O_NONBLOCK); icb_debug ($output_window, 1, "Command FIFO %s is open", $icbmfifo); while ($input_thread_running > 0) { $rout = $rin = $fifodata = ''; vec($rin, fileno(FIFO), 1) = 1; select($rout = $rin, undef, undef, 0.01); if (vec($rout, fileno(FIFO), 1)) { chomp($fifodata = ); icb_debug ($output_window, 1, "Read '%s' from FIFO\n", $fifodata); next if ($fifodata eq '/x' || $fifodata eq '/exit' || $fifodata eq '/quit'); handle_input($fifodata, $output_window, $input_window, $status_line, $connection) if (length($fifodata)); } threads->yield if ($input_thread_running > 0); } icb_debug ($output_window, 1, "Input thread stopped; fifocmd() exiting"); close (FIFO); unlink ($icbmfifo); } else { icb_print ($output_window, 'status', "Could not open %s as FIFO", $icbmfifo); icb_print ($output_window, 'status', "Remote control functionality will not be available."); } }