Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"

Solve IO::Pty warning issues from Net::OpenSSH

by dkhosla1 (Sexton)
on Jun 22, 2024 at 21:30 UTC ( [id://11160172]=perlquestion: print w/replies, xml ) Need Help??

dkhosla1 has asked for the wisdom of the Perl Monks concerning the following question:


I am using Net::OpenSSH, and if providing a password to a connection, it uses the IO:Pty package and gives a warning.

The connection is successful. The issue seems to be with grantpt()

WARN: IO::Pty::new:24: IO::Tty::pty_allocate(nonfatal): grantpt(): Operation not permitted

With debug it shows 'trying grantpt() ...' before this message.

1) any suggestions on how to have grantpt() be successful or not be attempted?

2) Or suppress that specific message or worst case suppress all warning messages from IO::Pty (It was suggested that I use '{ no warning; .. } but I don't want to suppress warnings from Net::OpenSSH itself)


Replies are listed 'Best First'.
Re: Solve IO::Pty warning issues from Net::OpenSSH
by syphilis (Archbishop) on Jun 23, 2024 at 10:28 UTC
    any suggestions on how to have grantpt() be successful or not be attempted?

    The issue arises because HAVE_GRANTPT is defined when building IO::Tty.
    I don't know why that symbol is defined. It appears to NOT be defined by IO::Tty.
    One possible solution (which should avoid the call to grantpt) is, in IO-Tty-1.20 source, to apply this simple patch to Tty.xs:
    --- Tty.xs 2023-12-29 04:53:07.000000000 +1100 +++ Tty.xs_modified 2024-06-23 20:25:51.411610800 +1000 @@ -257,6 +257,7 @@ { mysig_t old_signal; old_signal = mysignal(SIGCHLD, SIG_DFL); +#undef HAVE_GRANTPT #if defined(HAVE_GRANTPT) #if PTY_DEBUG if (print_debug)
    Then rebuild and reinstall IO-Tty-1.20.

Re: Solve IO::Pty warning issues from Net::OpenSSH
by bliako (Abbot) on Jun 23, 2024 at 11:02 UTC

    In the XS source code at, running the code it bothers you is controlled by the constant HAVE_GRANTPT which I believe is set during compiling Perl. So, it will try running it if your Perl installation found that you have it. The warning is about permissions. So perhaps you can investigate and solve it at the OS level.

    Warnings can be controlled also at the block level. But you can not tell a module to stop warning unless that module has this line at its preamble: use warnings::register; in which case you use no warnings 'My::Module'; but that means you raise an issue with the author to include that line. Note that this method failed for me for some reason...

    Your other option is to create a warn-handler and filter out (via regex) that particular warning:

    # from +?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_c +ontent=share_button local $SIG{__WARN__} = sub { return if $_[0] =~ /IO::Pty blah blah/; print STDERR "$_\n"; };

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11160172]
Approved by talexb
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (4)
As of 2024-07-18 05:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.