Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^4: Perl/Tk and exit(0) [Tk::exit]

by kcott (Archbishop)
on Apr 04, 2020 at 06:59 UTC ( [id://11115022]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Perl/Tk and exit(0) [Tk::exit]
in thread Perl/Tk and exit(0)

G'day jcb,

I'm unsure whether you posted this to corroborate what I said or correct something you believed I had wrong in some way. So, purely by way of clarification:

  • I was pointing out that the exit in a Tk script was the one described in https://metacpan.org/pod/distribution/Tk/pod/exit.pod and not the one described in https://perldoc.perl.org/functions/exit.html.
  • I was not, in any way, suggesting that changing from Tk::exit to CORE::exit would be beneficial for the OP. In fact, I wrote: "Knowing that doesn't help the OP ...".
  • What you wrote ("As I understand, the two exit procedures ...") pretty much paraphrases what's in the Tk::exit documentation; i.e. "Using exit from a forked process will terminate both the child process and the parent process. As Tk::exit is imported by default one should use CORE::exit in the forked process instead.".
  • The reason to generally prefer Tk::exit over CORE::exit is given in the preceding paragraph: "If calling exit from code invoked via a Tk callback then this Tk version of exit cleans up more reliably than using the perl exit.".

If there was any miscommunication or misunderstanding, I hope that clears it up.

— Ken

Replies are listed 'Best First'.
Re^5: Perl/Tk and exit(0) [Tk::exit]
by jcb (Parson) on Apr 04, 2020 at 23:33 UTC

    It was intended to corroborate and to point out a difference that helps to explain why Tk replaces exit. My understanding of the two is from the documentation and my experience, which does not include Tk on Windows, so the difference I know about is that Tk::exit reliably destroys all of the MainWindows, while CORE::exit allows a forked worker (such as performing an LWP request without blocking the GUI) to safely exit after reporting its results back. On X11, calling Tk::exit from a forked child also causes the parent to exit.

      ++ Thanks for the reply. Looks like we're all good. :-)

      — Ken

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (6)
As of 2024-04-19 08:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found