1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-10-27 02:33:19 +00:00

replace fork to thread

This commit is contained in:
nishiki 2016-07-14 00:12:21 +02:00
parent 4d783e88a4
commit 1edb10ae49

View file

@ -222,25 +222,14 @@ class Cli
pid = nil pid = nil
# Security: force quit after 90s # Security: force quit after 90s
pid_s = Process.fork do Thread.new do
begin sleep 90
sleep 90 exit
Process.kill(3, Process.ppid)
rescue Interrupt
exit
end
end end
while true while true
choice = ask(I18n.t('form.clipboard.choice')).to_s choice = ask(I18n.t('form.clipboard.choice')).to_s
if not pid.nil?
Clipboard.clear
Process.kill(9, pid)
pid = nil
end
case choice case choice
when 'q', 'quit' when 'q', 'quit'
break break
@ -253,14 +242,10 @@ class Cli
Clipboard.copy(@mpw.get_password(item.id)) Clipboard.copy(@mpw.get_password(item.id))
puts I18n.t('form.clipboard.password').yellow puts I18n.t('form.clipboard.password').yellow
pid = Process.fork do Thread.new do
begin sleep 30
sleep 30
Clipboard.clear Clipboard.clear
rescue Interrupt
exit
end
end end
else else
@ -270,13 +255,8 @@ class Cli
end end
Clipboard.clear Clipboard.clear
rescue SystemExit, Interrupt rescue SystemExit, Interrupt
Clipboard.clear Clipboard.clear
ensure
Process.kill('HUP', pid) if not pid.nil?
Process.kill('HUP', pid_s)
end end
# Display the wallet # Display the wallet