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

Thomas Schwinge <[email protected]>
Newsgroups gmane.lisp.scheme.scheme48
Message-ID <[email protected]>
Hello!

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>
    
    int
    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;
    }


Regards,
 Thomas
signature.asc (application/pgp-signature, 191 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFKiw0msmqaiQAHQR4RAktyAJ92eO6VUBnb0jKh7sJtz6h6uJUvvACgswBV
pyFT4M4+STFZzQGoA/rVYNI=
=k88k
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.