Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qx seems to loose the subpr. way for print /dev/tty #8374

Closed
p5pRT opened this issue Mar 17, 2006 · 12 comments
Closed

qx seems to loose the subpr. way for print /dev/tty #8374

p5pRT opened this issue Mar 17, 2006 · 12 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 17, 2006

Migrated from rt.perl.org#38748 (status was 'open')

Searchable as RT38748$

@p5pRT
Copy link
Author

p5pRT commented Mar 17, 2006

From ende@telefonica.net

Created by juanfc@lcc.uma.es

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.

In the "daemonized" perl script, that has the loop​:

while (1) {
  `/Users/home/bin/tclprocThatusesdevtty.tcl -a`;
  # .....
  sleep 600;
}

only the first time the Tcl program is runned, the messages sent
by the Tcl program are really sent to the /dev/tty. Then, no more
messages are seen in the Terminal. The perl script seems
running ok all the time and the Tcl program also seems been called...

If I do the same stuff with sh

while [ 1 -eq 1 ]; do
  /Users/juanfc/bin/drg.tcl -a
  # ....
  sleep 600
done

there is no problem at all.

Perl Info

Flags:
     category=core
     severity=high

Site configuration information for perl v5.8.6:

Configured by root at Sun Mar 20 16:31:42 PST 2005.

Summary of my perl5 (revision 5 version 8 subversion 6) configuration:
   Platform:
     osname=darwin, osvers=8.0, archname=darwin-thread-multi-2level
     uname='darwin b28.apple.com 8.0 darwin kernel version 7.5.0: thu  
mar 3 18:48:46 pst 2005; root:xnuxnu-517.99.13.obj~1release_ppc power  
macintosh powerpc '
     config_args='-ds -e -Dprefix=/usr -Dccflags=-g  -pipe  - 
Dldflags=-Dman3ext=3pm -Duseithreads -Duseshrplib'
     hint=recommended, useposix=true, d_sigaction=define
     usethreads=define use5005threads=undef useithreads=define  
usemultiplicity=define
     useperlio=define d_sfio=undef uselargefiles=define usesocks=undef
     use64bitint=undef use64bitall=undef uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-g -pipe -fno-common -DPERL_DARWIN -no-cpp- 
precomp -fno-strict-aliasing -I/usr/local/include',
     optimize='-Os',
     cppflags='-no-cpp-precomp -g -pipe -fno-common -DPERL_DARWIN -no- 
cpp-precomp -fno-strict-aliasing -I/usr/local/include'
     ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc.  
build 1809)', gccosandvers=''
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
     ivtype='long', ivsize=4, nvtype='double', nvsize=8,  
Off_t='off_t', lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags ='-L/usr/ 
local/lib'
     libpth=/usr/local/lib /usr/lib
     libs=-ldbm -ldl -lm -lc
     perllibs=-ldl -lm -lc
     libc=/usr/lib/libc.dylib, so=dylib, useshrplib=true,  
libperl=libperl.dylib
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags='-bundle -undefined dynamic_lookup -L/ 
usr/local/lib'

Locally applied patches:
     23953 - fix for File::Path::rmtree CAN-2004-0452 security issue
     33990 - fix for setuid perl security issues


@INC for perl v5.8.6:
     /sw/lib/perl5
     /sw/lib/perl5/darwin
     /System/Library/Perl/5.8.6/darwin-thread-multi-2level
     /System/Library/Perl/5.8.6
     /Library/Perl/5.8.6/darwin-thread-multi-2level
     /Library/Perl/5.8.6
     /Library/Perl
     /Network/Library/Perl/5.8.6/darwin-thread-multi-2level
     /Network/Library/Perl/5.8.6
     /Network/Library/Perl
     /System/Library/Perl/Extras/5.8.6/darwin-thread-multi-2level
     /System/Library/Perl/Extras/5.8.6
     /Library/Perl/5.8.1/darwin-thread-multi-2level
     /Library/Perl/5.8.1
     .


Environment for perl v5.8.6:
     DYLD_LIBRARY_PATH (unset)
     HOME=/Users/juanfc
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=/sw/bin:/sw/sbin:/Library/Tcl/bin:/bin:/sbin:/usr/bin:/usr/ 
sbin:/Developer/Tools:/usr/X11R6/bin:/usr/local/teTeX/bin/powerpc- 
apple-darwin-current:/Users/juanfc/bin:/Users/juanfc/ubin:/Users/ 
juanfc/perls:/opt/local/bin:.:/usr/local/bin
     PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
     PERL_BADLANG (unset)
     SHELL=/bin/tcsh


@p5pRT
Copy link
Author

p5pRT commented Mar 17, 2006

From @rgarcia

On 3/17/06, via RT ende <perlbug-followup@​perl.org> wrote​:

while (1) {
`/Users/home/bin/tclprocThatusesdevtty.tcl -a`;

What happens if you use system() instead of `` ? system doesn't
intercept the output of the command like `` does -- `` being intended
to capture output, not to simply run an external program.

 \# \.\.\.\.\.
 sleep 600;

}

only the first time the Tcl program is runned, the messages sent
by the Tcl program are really sent to the /dev/tty. Then, no more
messages are seen in the Terminal. The perl script seems
running ok all the time and the Tcl program also seems been called...

@p5pRT
Copy link
Author

p5pRT commented Mar 17, 2006

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Mar 17, 2006

From shouldbedomo@mac.com

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

@p5pRT
Copy link
Author

p5pRT commented Mar 18, 2006

From ende@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

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2016

From @dcollinsn

This ticket badly needs to be reviewed by a Darwin expert. Is there something that we need to work around on this OS? (Can you summarize it and update the ticket name?)

--
Respectfully,
Dan Collins

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2016

From [Unknown Contact. See original ticket]

This ticket badly needs to be reviewed by a Darwin expert. Is there something that we need to work around on this OS? (Can you summarize it and update the ticket name?)

--
Respectfully,
Dan Collins

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2016

@dcollinsn - Status changed from 'open' to 'stalled'

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2016

From @arc

Dan Collins via RT <perlbug-comment@​perl.org> wrote​:

This ticket badly needs to be reviewed by a Darwin expert. Is there something that we need to work around on this OS? (Can you summarize it and update the ticket name?)

I've tried and failed to reproduce this​:

$ uname -sr
Darwin 13.4.0
$ perl -wE 'say $^V'
v5.24.0
$ echo 'puts $tcl_version' | tclsh
8.6
$ cat outer.pl
#! /usr/bin/env perl
while (1) {
  `./inner.tcl -a`;
  sleep 2;
}
$ cat inner.tcl
#! /usr/bin/env tclsh
exec echo foo >/dev/tty
$ chmod +x outer.pl inner.tcl
$ ./outer.pl
foo
foo
foo
^C

It seems to me that whatever bug existed when this ticket was filed a
decade ago has subsequently been fixed, and I suggest this ticket can
therefore be closed now. Alternatively, if the original requestor can
submit complete, self-contained scripts that still reproduce the
problem (the incomplete Tcl program in transaction 131257 merely fails
with a "no such variable" error before it runs anything at all), we
can surely investigate further.

--
Aaron Crane ** http​://aaroncrane.co.uk/

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2016

From @dcollinsn

On Tue Jul 12 10​:18​:05 2016, arc wrote​:

Dan Collins via RT <perlbug-comment@​perl.org> wrote​:

This ticket badly needs to be reviewed by a Darwin expert. Is there
something that we need to work around on this OS? (Can you summarize
it and update the ticket name?)

I've tried and failed to reproduce this​:

$ uname -sr
Darwin 13.4.0
$ perl -wE 'say $^V'
v5.24.0
$ echo 'puts $tcl_version' | tclsh
8.6
$ cat outer.pl
#! /usr/bin/env perl
while (1) {
`./inner.tcl -a`;
sleep 2;
}
$ cat inner.tcl
#! /usr/bin/env tclsh
exec echo foo >/dev/tty
$ chmod +x outer.pl inner.tcl
$ ./outer.pl
foo
foo
foo
^C

It seems to me that whatever bug existed when this ticket was filed a
decade ago has subsequently been fixed, and I suggest this ticket can
therefore be closed now. Alternatively, if the original requestor can
submit complete, self-contained scripts that still reproduce the
problem (the incomplete Tcl program in transaction 131257 merely fails
with a "no such variable" error before it runs anything at all), we
can surely investigate further.

Thank you, Aaron.

Taking with the intent to close in 7 days unless there is anyone who can provide a test case that we can reproduce.

--
Respectfully,
Dan Collins

@p5pRT
Copy link
Author

p5pRT commented Jul 12, 2016

The RT System itself - Status changed from 'stalled' to 'open'

@toddr
Copy link
Member

toddr commented Jan 31, 2020

I think this case was not closed by mistake. Closing it now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants