If bind was called before the process registered with the IRMd, the
bind operation would fail. The IRMd will now retry binding until the
process is known or exits.
Signed-off-by: Dimitri Staessens <dimitri.staessens@xxxxxxxx>
---
src/irmd/main.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/src/irmd/main.c b/src/irmd/main.c
index 19bcc8c..02669ce 100644
--- a/src/irmd/main.c
+++ b/src/irmd/main.c
@@ -758,7 +758,7 @@ static int bind_program(char * prog,
static int bind_process(pid_t pid,
char * name)
{
- char * name_dup = NULL;
+ char * name_dup = NULL;
struct proc_entry * e = NULL;
struct reg_entry * re = NULL;
@@ -767,7 +767,11 @@ static int bind_process(pid_t pid,
pthread_rwlock_wrlock(&irmd.reg_lock);
- e = proc_table_get(&irmd.proc_table, pid);
+ while(!kill(pid, O)) {
+ e = proc_table_get(&irmd.proc_table, pid);
+ if (e == NULL)
+ sched_yield();
+ }
if (e == NULL) {
log_err("Process %d does not exist.", pid);
pthread_rwlock_unlock(&irmd.reg_lock);
--
2.17.1