In the XS source code at https://metacpan.org/release/TODDR/IO-Tty-1.20/source/Tty.xs#L256, 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 https://www.reddit.com/r/perl/comments/1256khf/comment/je3wh0m/ +?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"; };

In reply to Re: Solve IO::Pty warning issues from Net::OpenSSH by bliako
in thread Solve IO::Pty warning issues from Net::OpenSSH by dkhosla1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.