[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Autotools macro to test for pthreads fails with "Resource lost" on hurd


On Tue, Aug 18, 2009 at 09:15:54PM +0200, I wrote:
>     #include <pthread.h>
>     int
>     main(void)
>     {
>       pthread_kill(pthread_self(), 0);
>     }

This should be valid code.

>     tschwinge@flubber:~ $ uname -a
>     GNU flubber 0.3 GNU-Mach 1.3.99/Hurd-0.3 i386-AT386 GNU
>     tschwinge@flubber:~ $ gcc p.c -lpthread
>     tschwinge@flubber:~ $ ./a.out 
>     Resource lost

Looking at libpthread/sysdep/hurd/pt-kill.c (see below) which invokes
glibc/hurd/hurd-raise.c:_hurd_raise_signal, and comparing that to Linux'
kernel/signal.c:do_tkill, I think that we're missing a check to inhibit
that a signal == 0 is actually risen.  In the latter Linux function, the
following is said about this check: ``The null signal is a permissions
and process existence probe.  No signal is actually delivered.''  Where
do we need to add this check?  Or is the glibc code already supposed to
handle that correctly?  Roland?

For easy reference, here's pthread_kill:

    #include <pthread.h>
    #include <assert.h>
    #include <signal.h>
    #include <hurd/signal.h>
    #include <pt-internal.h>
    pthread_kill (pthread_t thread, int sig)
      struct __pthread *pthread;
      struct hurd_signal_detail detail;
      struct hurd_sigstate *ss;
      /* Lookup the thread structure for THREAD.  */
      pthread = __pthread_getid (thread);
      if (pthread == NULL)
        return ESRCH;
      ss = _hurd_thread_sigstate (pthread->kernel_thread);
      assert (ss);
      detail.exc = 0;
      detail.code = sig;
      detail.error = 0;
      _hurd_raise_signal (ss, sig, &detail);
      return 0;


Attachment: signature.asc
Description: Digital signature

Reply to: