Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: perl -d myprog autostarts - but only in one specific directory

by ikegami (Patriarch)
on Jan 18, 2022 at 14:09 UTC ( #11140564=note: print w/replies, xml ) Need Help??


in reply to perl -d myprog autostarts - but only in one specific directory

Could the debugger be reading from con? That's the equivalent of /dev/tty on Windows.

Upd: I can't replicate your result exactly, but the existence of con is definitely a problem. In my test in Linux, it also wrote to con, which it then read, which caused more output, which ...

Replies are listed 'Best First'.
Re^2: perl -d myprog autostarts - but only in one specific directory
by bliako (Monsignor) on Jan 18, 2022 at 15:19 UTC

    I can replicate on Linux. With an empty con dir in current dir, debugger does not break until program exits. If ./con is a file, it writes to it and enters some kind of never-ending loop, as you say.

    strace perl -d a.pl shows this:

    newfstatat(AT_FDCWD, "con", ..., ...)

    Then, if con is found, it is opened with openat(AT_FDCWD, "con", O_RDWR|O_CREAT|O_TRUNC|O_CLOEXEC, 0666) and it is writing to it.

    perl a.pl does not look for con

    The flag AT_FDCWD has the meaning of "relative to current dir", i.e. where you execute from and not where script is located.

    documentation mentions it:

    If there is a TTY, we have to determine who it belongs to before we ca +n proceed. If this is a slave editor or graphical debugger (denoted b +y the first command-line switch being '-emacs'), we shift this off an +d set $rl to 0 (XXX ostensibly to do straight reads). We then determine what the console should be on various systems: Cygwin - We use stdin instead of a separate device. Windows or MSDOS - use con. AmigaOS - use CONSOLE:. VMS - use sys$command. Unix - use /dev/tty.

    Question is: why on Unix con has a role?

    And I find this in source of perl5db.pl:

    elsif ( $^O eq 'dos' or -e "con" or $^O eq 'MSWin32' ) { $console = "con"; }

    -e "con" short-circuits the Unix check further down (if file or dir "con" exists in current dir): if( -e '/dev/tty'). Surely a bug AFAICS.

    bw, bliako

      > Surely a bug AFAICS.

      AFAICF = as far as I can fix :-)

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

        I don't think the fix will work. I made a comment below. Thanks, I did not know it was that simple

Re^2: perl -d myprog autostarts - but only in one specific directory
by ibm1620 (Pilgrim) on Jan 18, 2022 at 22:43 UTC
    Holy smokes.

    That was it. I deleted con/ and all is well. Incidentally, I don't see any evidence that anything was written into the directory, which just contained a small perl program whose purpose I no longer recall.

    Thank you all.

Re^2: perl -d myprog autostarts - but only in one specific directory
by bliako (Monsignor) on Jan 19, 2022 at 13:35 UTC

    I did not know of that CON thingy and your mention let me to investigate it. ++

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11140564]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2022-06-29 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My most frequent journeys are powered by:









    Results (94 votes). Check out past polls.

    Notices?