⚲
Project
General
Profile
Sign in
Register
Home
Projects
Help
Search
:
Ruby master
All Projects
Ruby
»
Ruby master
Overview
Activity
Roadmap
Issues
Repository
Like
Download (534 Bytes)
Bug #18811
» ptytest.rb
hspem (Per-Erik Martin)
, 05/30/2022 07:26 AM
#!/usr/bin/env ruby
require
'pty'
if
ARGV
.
length
==
1
$command
=
ARGV
[
0
]
else
$command
=
'echo foo'
end
$exit_status
=
nil
begin
PTY
.
spawn
(
$command
)
do
|
r
,
w
,
pid
|
w
.
close
begin
r
.
each
do
|
line
|
puts
"Got line
\"
#{
line
.
chomp
}
\"
"
end
rescue
Errno
::
EIO
# ignore
rescue
=>
e
$stderr
.
puts
"Read error:
#{
e
}
"
ensure
Process
.
wait
pid
end
$exit_status
=
$?
.
exitstatus
end
rescue
=>
e
$stderr
.
puts
"PTY.spawn error:
#{
e
}
"
end
puts
"Exit status
#{
$exit_status
}
"
« Previous
1
2
Next »
(1-1/2)
Loading...