0

GNOME developers removed option disable-factory from gnome-terminal in about version 3.8. While in wheezy there is older version, in jessie there is 3.14.

When that option was used gnome-terminal (<3.8) left waiting until the stuff running it it ended. In newer version gnome-terminal returns immediately after the window is launched. What is worse, the process running in the window has main gnome-terminal process as parent, so I cannot waitpid for it (as this is reserved only for child processes).

I have a Ruby script that launches a tool in gnome-terminal and have to wait until the process of that tool ends. Anyone has an idea how to achieve that without consuming too much resources on the loop checking status of the process with given PID?

It has to be possible to do in Ruby or Bash.

Nick Veys
  • 23,458
  • 4
  • 47
  • 64
Michał Fita
  • 1,183
  • 1
  • 7
  • 24

1 Answers1

0

Take a look at the sys-proctable gem, it might be what you need.

(524)⚡️ irb
2.1.2 :001 > require 'sys/proctable'
 => true 
2.1.2 :002 > s = Sys::ProcTable.ps(88964)
 => #<struct Struct::ProcTableStruct pid=88964, ppid=88962, pgid=88964 ...> 
2.1.2 :003 > s.comm
 => "bash"
2.1.2 :004 > s.state
 => "run" 

After that it should be something simple like a loop:

loop do
  s = Sys::ProcTable.ps(88964)
  break if s.nil? || s.state != 'run'
  sleep(1)
end
Nick Veys
  • 23,458
  • 4
  • 47
  • 64