[813] in Pthreads mailing list archive

home help back first fref pref prev next nref lref last post

Re: Strange behaviour

daemon@ATHENA.MIT.EDU (David Frascone)
Thu Mar 11 12:35:07 1999

Date: Thu, 11 Mar 1999 09:17:17 -0800 (PST)
From: David Frascone <chaos@mindspring.com>
Reply-To: chaos@mindspring.com
To: Wolfgang =?iso-8859-1?Q?R=F6mer?= <Wolfgang.Roemer@brokat.com>
Cc: pthreads@MIT.EDU
In-Reply-To: <36E7E578.A9A43086@brokat.com>


You probably need to define _REENTRANT:

gcc -o test1 test1.c -D_REENTRANT -lpthreads

On Thu, 11 Mar 1999, Wolfgang [iso-8859-1] R=F6mer wrote:

> Hi,
>=20
> some strange behaviour occured to me concerning the following code:
>=20
>=20
> -----------------cut here--------------------------------
>=20
> #include <sys/types.h>
>=20
> /************************************************************************=
********
>=20
>  * This program (named test1) forces an error when compiled and linked
> as follows:
>  *
>  *       gcc -o test1 test1.c -lpthreads
>  *
>  * I know it seems strange to link this program with the pthreads
> library because
>  * it does not use pthreads, but this test program is only a part of a
> much larger
>  * program that uses pthreads and I could not get it to work on Linux
> (It works great
>  * on solaris, aix and hpux). In 2 days of work I could reduce the
> problem to this
>  * dummy program. Linking without the pthreads makes the program run
> fine.
>  *
>  * Sympthoms:
>  * CPU load is 100% and the child never stops
>  *
>  * Environment:
>  * SuSE Linux 5.3, Kernel 2.0.36, gcc-2.7.2.1, libc5.4.33,
> libpthreads1.60.4
>  *
>  * (The problems appears with Kernel 2.0.35 as well.)
>  ************************************************************************=
********/
>=20
>=20
>=20
> int main()
> {
>    pid_t pid =3D fork();
>    if( pid < 0 )
>    {
>       perror( "test" );
>       exit(1);
>    }
>    else if( pid > 0 )
>    {
>       /* this is the parent */
>       waitpid( pid, NULL, 0 );
>       exit(0);
>    };
>=20
>    /* this is the child */
>    sleep(10);
>=20
>    exit(0);
> }
>=20
>=20
> -------------------cut here-------------------------------
>=20
> Any ideas
>=20
> Wolfgang
>=20


home help back first fref pref prev next nref lref last post