[pass] [PATCH v2] clip: don't race between pass instances in restore

Matthew Cengia mattcen at gmail.com
Thu Mar 20 14:54:35 CET 2014


On 2014-03-20 00:48, Jason A. Donenfeld wrote:
> We now make sure a previous pass clip restore finishes immediately when
> copying another password to the clipboard.
> 
> This is currently only implemented on Linux.
[...]
> +	sleep_argv0="password store sleep on display $DISPLAY"
> +	kill -9 $(grep -l -r --include="cmdline" "^$sleep_argv0" /proc/ 2>/dev/null | sed -n 's:/proc/\([0-9]\+\)/.*:\1:p' | sort | uniq) 2>/dev/null && sleep 0.1

The following replacement line for the above uses POSIX 2008-compliant
options for both 'ps' and 'kill' and therefore, assuming Bash (as
opposed to sh) and a version of sleep that supports fractions of a
second (non-POSIX), it should work fine everywhere that is
POSIX-compliant. I've tested it on both Linux and OSX.

  while read -r pid cmd; do [[ $cmd = $sleep_argv0* ]] && kill -9 "$pid"; done < <(ps -opid=,args= -u"$(id -u)") && sleep 0.1

It also turns out to be shorter. Who'd have thought it!?

-- 
Regards,
Matthew Cengia
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 966 bytes
Desc: Digital signature
URL: <http://lists.zx2c4.com/pipermail/password-store/attachments/20140321/b9f70c47/attachment.asc>


More information about the Password-Store mailing list