gopass icon indicating copy to clipboard operation
gopass copied to clipboard

`gopass show -c` process never stops

Open freijon opened this issue 4 years ago • 2 comments

Summary

I tried running the command described in setup.md: gopass ls --flat | dmenu | xargs --no-run-if-empty gopass show -c. This apparently launches two gopass commands which run forever.

Steps To Reproduce

  • Execute gopass ls --flat | dmenu | xargs --no-run-if-empty gopass show -c
  • It will show a message that the clipboard will be cleared after 45 seconds. But after 45 seconds the process keeps running and I have to manually kill it with Ctrl-C.
  • Check with ps ax | grep gopass that there are still two gopass processes running: gopass show -c <pass> and gopass unclip --timeout 45

Expected behavior

45 seconds after the command has been executed all gopass processes should stop.

Environment

  • OS: Gentoo Linux
  • OS version: Linux gentoo-y700 5.10.1-gentoo
  • gopass Version: gopass 1.10.1 (2020-12-16 05:10:34) go1.15.5 linux amd64
  • Installation method: app-admin/gopass ebuild

freijon avatar Dec 16 '20 05:12 freijon

What happens if you run gopass show -c nameofanentry ? Does it also keep running ?

AnomalRoil avatar Dec 17 '20 10:12 AnomalRoil

The command starts and keeps running forever. However, there is no message about 45 seconds.

EDIT: I'm using Wayland, maybe that's the issue?

freijon avatar Dec 17 '20 15:12 freijon

@AnomalRoil, @dominikschulz: I'm able to reproduce this issue, but using different steps:

  1. I assume you already have password store with secret called "test".
  2. Run gopass
  3. In gopass built-in shell, run show -c test few times in a row without waiting 45 seconds.
  4. Switch to another terminal tab and run pgrep --list-full gopass. Example output will look like this:
1000 gopass
1001 gopass
1002 gopass
1003 gopass unclip --timeout 45

Process with PID 1000 is gopass built-in shell, PIDs 1001 and 1002 are zombie processes left after gopass unclip and PID 1003 is most recent gopass unclip. After 45 seconds, PID 1003 becomes zombie as well. Those processes are there until parent process exits.

I'm not Go developer, but I think I found the solution to this issue. Here is Stack Overflow question about similar issue. I also found that Process.Kill "does not wait until the Process has actually exited." and you need to Process.Wait for those processes to exit after they get killed. Basically they are zombies until the parent process reuqests exit status from them.

I think that modifying killProc function to make it wait after killing the process should be enough to fix this issue.

ghost avatar Sep 25 '22 22:09 ghost

@fm2mwvtsp8vqtuy5 Thanks for the detailed explanation. Unfortunately I was not able to reproduce. At least on my system (Linux) killPrecedessors does seem to take care of any lingering processes.

But you are right that we're not using Process.Kill according to documentation, so we'll fix that :+1:

dominikschulz avatar Sep 26 '22 16:09 dominikschulz

@dominikschulz: I'm glad I could help you and I'm happy to see that you fixed it so quick.

ghost avatar Sep 26 '22 17:09 ghost