0

I am trying to handle all the possible return values of pthread_timedjoin_np(), but I did not quite understand, when does it return EBUSY?

If the thread returns within the given time pthread_timedjoin_np() always returns zero, while if time has passed I get ETIMEDOUT. What do I have to do to trigger EBUSY?

madmurphy
  • 1,451
  • 11
  • 20
  • https://github.com/bminor/glibc/blob/b92a49359f33a461db080a33940d73f47c756126/nptl/pthread_timedjoin.c -> https://github.com/bminor/glibc/blob/b92a49359f33a461db080a33940d73f47c756126/nptl/pthread_join_common.c I don't see it, so never? – KamilCuk Jan 27 '22 at 18:25

1 Answers1

1

I did not quite understand, when does it return EBUSY?

Never.

The man page that you are reading is for both pthread_tryjoin_np and pthread_timedjoin_np. pthread_tryjoin_np will return with EBUSY when "thread had not yet terminated at the time of the call".

These functions can fail with the same errors as pthread_join(3).
pthread_tryjoin_np() can in addition fail with the following error:

EBUSY thread had not yet terminated at the time of the call.

pthread_timedjoin_np() can in addition fail with the following errors:

EINVAL abstime value is invalid (tv_sec is less than 0 or tv_nsec is greater than 1e9).

ETIMEDOUT The call timed out before thread terminated.

KamilCuk
  • 120,984
  • 8
  • 59
  • 111