Skip to contentSkip to conversation

sem_timedwait return value

Xenomai-help Jeff Webb 2 participants 2 messages Dec 1, 2006

lore
Share & tools
lore

Jeff Webb

author
#0 lore raw

In my userspace POSIX program, I get a '-1' return value from sem_timedwait, even when the function succeeds. When the function succeeds, errno is '-1' as well. I am using this workaround at the moment:

     result = sem_timedwait(&cas_sem, &wake_time);
     if (result < 0 && errno > 0) /* errno > 0 to work around xenomai bug */
       {
         print_msg(WARN_MSG, "sem_wait returned with error code %d\n",
                   errno);
         continue;
       }

I am using xenomai 2.2.4, but I think the problem exists in other branches as well. I believe the attached patch against the trunk should fix the problem. Do you agree?

Thanks,

Jeff

skins/posix/syscall.c +1 -1
Index: ksrc/skins/posix/syscall.c
===================================================================
@@ -492,7 +492,7 @@
 			    &ts,
 			    (void __user *)__xn_reg_arg2(regs), sizeof(ts));
 
-	return sem_timedwait(&sm.native_sem, &ts) == 0 ? : -thread_get_errno();
+	return sem_timedwait(&sm.native_sem, &ts) == 0 ? 0 : -thread_get_errno();
 }
 
 static int __sem_trywait(struct task_struct *curr, struct pt_regs *regs)
#1 lore raw
Quoted 10 lines · Jeff Webb

In my userspace POSIX program, I get a '-1' return value from sem_timedwait, even when the function succeeds. When the function succeeds, errno is '-1' as well. I am using this workaround at the moment:

      result = sem_timedwait(&cas_sem, &wake_time);
      if (result < 0 && errno > 0) /* errno > 0 to work around xenomai bug */
        {
          print_msg(WARN_MSG, "sem_wait returned with error code %d\n",
                    errno);
          continue;
        }
Quoted 2 lines

I am using xenomai 2.2.4, but I think the problem exists in other branches as well. I believe the attached patch against the trunk should fix the problem. Do you agree?

Oops, yes. This bug belongs to me. Applied, thanks.

Quoted 7 lines

Thanks,

Jeff
_______________________________________________
Xenomai-help mailing list
[email protected]
https://mail.gna.org/listinfo/xenomai-help

Signature · 1 line
Philippe.