On Wed, Oct 18, 2000 at 02:31:47PM +1000, Lachlan Holmes wrote:
>
> In a very simple test program I have created, I get a memory fault when I
> try to do a pth_join on SCO OpenServer 5.0.5, but it works fine on HPUX
> 10.20. Ideas? Should I reinstall pth perhaps? Source follows.
A reinstall is probably not necessary. Almost certainly it is because
you're passing hThread to pth_join, which is uninitialized. Try:
hThread = pth_spawn(PTH_ATTR_DEFAULT, clientThread, 0);
if (hThread == NULL) {
.
.
.
/* no need to check - it can't fail! */
pth_join(hThread, (void **)&valuePtr);
You're bizarro handling of valuePtr probably doesn't have anything to do
with your error, but you should probably just declare it as an "int", as
suggested.
Shane
> int
> main() {
> pth_t hThread;
> int value = 0;
> int *valuePtr;
>
> valuePtr = (int *)malloc(sizeof(int));
> if (valuePtr == NULL) {
> perror("malloc return");
> exit(1);
> }
> valuePtr = &value;
>
> if (pth_init() == FALSE) {
> perror("pth_init returned");
> exit(1);
> }
>
> printf("In main\n");
>
> if (pth_spawn(PTH_ATTR_DEFAULT, clientThread, 0) == NULL) {
> perror("pth_spawn returned");
> exit(1);
> }
>
> printf("Before join\n");
>
> if (pth_join(hThread, (void **)&valuePtr) == FALSE) {
> perror("pth_join returned");
> exit(1);
> }
>
> printf("In main, after pth ran.\n");
>
> if (pth_kill() == FALSE) {
> perror("pth_kill returned");
> exit(1);
> }
> return 0;
> }
>
> void *
> clientThread(void *param) {
> printf("In thread\n");
> return 0;
> }
______________________________________________________________________
GNU Portable Threads (Pth) http://www.gnu.org/software/pth/
User Support Mailing List [EMAIL PROTECTED]
Automated List Manager (Majordomo) [EMAIL PROTECTED]