mirror of
https://github.com/nishiki/manage-password.git
synced 2025-02-21 10:20:05 +00:00
replace fork to thread
This commit is contained in:
parent
4d783e88a4
commit
1edb10ae49
1 changed files with 6 additions and 26 deletions
|
@ -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
|
||||||
|
|
Loading…
Add table
Reference in a new issue