develooper Front page | perl.perl5.porters | Postings from March 2006

Re: [perl #38748] qx seems to loose the subpr. way for print /dev/tty

From:
ende
Date:
March 17, 2006 17:21
Subject:
Re: [perl #38748] qx seems to loose the subpr. way for print /dev/tty
Message ID:
69C50801-5051-46C1-AE3C-15B10F2C55BD@telefonica.net


#!/usr/local/bin/perl
#
# it is the 5.8.8
#
# drgrun.pl
#
# this is script that never ends (is _like_ a daemon)
#
#

while (1) {
     `/Users/me/bin/script.tcl -a`;

     sleep 600;
}

# END

# ####################
# Tcl script script.tcl

eval [list exec echo >/dev/tty  " -->> \[$cola\] [string range  
[urldecod [file tail $que]] 0 $cosaEnActualL]" ]


# ####################

# this script calls programs that could use stdout

# The first time the script is called the echo > /dev/tty works but,  
then
# it gets dummy.  If you run it in sh

#!/bin/bash

while [ 1 -eq 1 ]; do
     /Users/me/bin/script.tcl -a

     sleep 600
done

# all goes well, no problem.  bash does not interfere with the output of
# the Tcl script.  I don't like to use sh because it uses an external
# program, sleep...



El 17/03/2006, a las 16:05, Dominic Dunlop via RT escribió:

> On 2006–03–17, at 09:40, ende (via RT) wrote:
>
>> I send messages through /dev/tty with
>>
>> 	exec echo >/dev/tty
>>
>> in a tcl script that is called from a Perl script.
>>
>> The Perl script is on forever with a loop, allowing me
>> a more easy control of both the Tcl script and the frequency
>> and actions I want the daemon do each 10 minutes.
>
> Can you make a short script (or pair of scripts) in pure Perl that
> show the problem? I ask because, if the process really is a daemon,
> it should not have a controlling terminal, and so /dev/tty should not
> be openable at all (not even once). Here's an example on Mac OS X
> (your platform -- basically BSD-ish):
>
> $ perl -MPOSIX=setsid -lwe 'unless (fork) {setsid; qx(tty > /dev/
> tty); sleep 300}'
> sh: line 1: /dev/tty: Device not configured
>
> and the same on PPC Linux:
>
> $ perl -MPOSIX=setsid -lwe 'unless (fork) {setsid; qx(tty > /dev/
> tty); sleep 300}'
> sh: /dev/tty: No such device or address
>
> (In both cases, we are seeing a complaint sent by the shell to
> standard error, which is still open, and which is not captured by qx 
> ().)
> -- 
> Dominic Dunlop
>
>




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About