mirror of
https://github.com/tmux/tmux.git
synced 2026-10-15 16:04:34 +00:00
retry reading session keyring if it grows
This commit is contained in:
@@ -35,18 +35,18 @@ void
|
|||||||
fork_session_keyring(void)
|
fork_session_keyring(void)
|
||||||
{
|
{
|
||||||
int32_t *keys = NULL;
|
int32_t *keys = NULL;
|
||||||
long size, n = 0, i;
|
long size = 0, n, i;
|
||||||
|
|
||||||
size = syscall(SYS_keyctl, KEYCTL_READ, KEY_SPEC_SESSION_KEYRING, NULL,
|
/* KEYCTL_READ returns the full size; retry if keys were added. */
|
||||||
0);
|
for (;;) {
|
||||||
if (size > 0) {
|
|
||||||
keys = xmalloc(size);
|
|
||||||
n = syscall(SYS_keyctl, KEYCTL_READ, KEY_SPEC_SESSION_KEYRING,
|
n = syscall(SYS_keyctl, KEYCTL_READ, KEY_SPEC_SESSION_KEYRING,
|
||||||
keys, size);
|
keys, size);
|
||||||
if (n > size)
|
if (n <= size)
|
||||||
n = size;
|
break;
|
||||||
n = n > 0 ? n / sizeof *keys : 0;
|
size = n;
|
||||||
|
keys = xrealloc(keys, size);
|
||||||
}
|
}
|
||||||
|
n = n > 0 ? n / sizeof *keys : 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Link the current session keyring into the thread keyring so we still
|
* Link the current session keyring into the thread keyring so we still
|
||||||
|
|||||||
Reference in New Issue
Block a user