mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: bert hubert <ahu@ds9a.nl>
To: Matthias Urlichs <smurf@smurf.noris.de>
Cc: linux-kernel@vger.kernel.org, molnar@elte.hu, phil-list@redhat.com
Subject: Re: BUG: NTPL: waitpid() doesn't return?
Date: Sat, 31 Jan 2004 20:19:23 +0100	[thread overview]
Message-ID: <20040131191923.GA21333@outpost.ds9a.nl> (raw)
In-Reply-To: <20040131181518.GB1815@kiste>

[Added Ingo & NPTL list]

[Matthias reports that threads forking multiple programs and running waitpid
 on them has problems] 

On Sat, Jan 31, 2004 at 07:15:19PM +0100, Matthias Urlichs wrote:

> > If they do not wait for a specific pid, the kernel is right. The kernel has
> > no way of knowing which process a specific waitpid is waiting for otherwise!
> > 
> Please check my original mail again. The thread _is_ waiting for a
> specific pid.

I can't reproduce this with 2.6.1, can you check if this works as intended
on your system? Should output:

Thread 0 Launched pid 10967
Thread 1 Launched pid 10971
Thread 1 waitpid for 10971 returned for 10971, status: 1
Thread 0 waitpid for 10967 returned for 10967, status: 3

This is with NPTL 0.60 (Debian Unstable).

./sleep program:

#!/bin/sh
sleep $1
exit $1

testcase.c:

#include <stdio.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <unistd.h>
#include <pthread.h>
#include <stdlib.h>

void unixDie(const char* what)
{
  perror(what);
  exit(1);
}
int s_counter;
void *func(void *p)
{
  pid_t pid;
  int status;
  int counter=s_counter++;

  pid=fork();
  if(pid<0)
    unixDie("doing fork");
  if(!pid) {
    char *arguments[]={"./sleep","",0};
    char str[10];
    sprintf(str,"%d",(int)p);
    arguments[1]=str;

    if(execve(arguments[0],arguments,0))
      unixDie("doing execve");
  }
  if(pid) {
    pid_t ret;
    printf("Thread %d Launched pid %d\n", counter, pid);
    ret=waitpid(pid, &status, 0);
    if(ret<0)
      unixDie("waitpid");

    printf("Thread %d waitpid for %d returned for %d, status: %d\n",counter, pid, ret, WEXITSTATUS(status));
  }

  return 0;
}


int main(int argc, char **argv)
{
  pthread_t t1, t2;
  pthread_create(&t1, 0, func,(void*)3);
  sleep(1);
  pthread_create(&t2, 0, func,(void*)1);

  pthread_join(t2,0);
  pthread_join(t1,0);
  return 0;
}


-- 
http://www.PowerDNS.com      Open source, database driven DNS Software 
http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO

  reply	other threads:[~2004-01-31 19:19 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-01-31 10:46 Matthias Urlichs
2004-01-31 15:37 ` bert hubert
2004-01-31 15:51   ` Matthias Urlichs
2004-01-31 16:18     ` bert hubert
2004-01-31 18:15       ` Matthias Urlichs
2004-01-31 19:19         ` bert hubert [this message]
2004-01-31 20:49           ` Matthias Urlichs
2004-01-31 21:18             ` bert hubert
2004-01-31 21:41               ` Matthias Urlichs
2004-01-31 21:52             ` Roland McGrath
2004-01-31 19:02 ` Linus Torvalds
2004-01-31 20:00   ` Matthias Urlichs
2004-01-31 20:58     ` Linus Torvalds
2004-01-31 21:11       ` Matthias Urlichs
2004-01-31 22:52         ` Linus Torvalds
2004-01-31 22:29       ` Matthias Urlichs

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20040131191923.GA21333@outpost.ds9a.nl \
    --to=ahu@ds9a.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=molnar@elte.hu \
    --cc=phil-list@redhat.com \
    --cc=smurf@smurf.noris.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome