develooper Front page | perl.beginners | Postings from January 2002

Re: why does open()ing happen only at the <FD> line ?

Thread Previous
From:
Michael Fowler
Date:
January 11, 2002 10:51
Subject:
Re: why does open()ing happen only at the <FD> line ?
Message ID:
20020111185010.GA15682@shoebox.net
On Fri, Jan 11, 2002 at 06:24:33PM +0000, Prahlad Vaidyanathan wrote:
> I'm guessing this has to do with how long it takes to invoke sudo (given
> system load, etc).

It does.


> But, all the same, shouldn't it wait for the password to be entered
> _before_ printing 'test' ? Now I'm totally stumped.

As mentioned by someone else (was it Bob Showalter?), with the way open
works you're not guaranteed of this.  If you want to make sure that what you
print out comes after the password is entered then you're going to have to
make provisions for that.  One possible solution (and I'm not certain it
works) is to select for readability on your handle; see perldoc -f select,
perldoc perlipc, and perldoc IO::Select.  Another is to read the password
yourself, then pass that on to sudo; this would require that sudo accept
passwords on standard input, and that you open the handle for reading and
writing with IPC::Open2.


Michael
--
Administrator                      www.shoebox.net
Programmer, System Administrator   www.gallanttech.com
--

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About