Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: pthreads and errno



On Monday, October 21, 2002, at 12:05  AM, Scott D.W. Rankin wrote:

Hello All,

I'm trying to port an email server program (BlitzMail, from Dartmouth College) to OS X, mostly for my own personal interest. It was originally written for NeXT, and has been ported to Digital Unix and Linux - so I figured that it wouldn't be too hard to port to OS X. However, during its configure script, it checks to see if errno is preserved between threads, and on OS X it's failing this test. I've modified the original test code from the configure script, and will include it below. It seems to me (with admittedly limited pthread experience) that it should work. However, it's not. Here's the source code and the output.


I'm assuming that the correct output is 0: Hello World! Going to sleep... Waking up...

As that is what got from a linux machine (ok, I added <errno.h> and linked in -lpthread).

On my mac, though, the output is unpredictable...

[01:30:14][jeremy:~]$ for ((i=1; i<10; i++)); do ./a.out; done;

0: Hello World!
Going to sleep...
Waking up...
Going to sleep...

0: Hello World!
Waking up...
main after sleep: errno = 2

0: Hello World!
Going to sleep...
Waking up...

0: Hello World!
Going to sleep...
Waking up...

0: Hello World!
Going to sleep...
Waking up...
main after sleep: errno = 2

0: Hello World!
Going to sleep...
Waking up...

0: Hello World!
Going to sleep...
Waking up...

0: Hello World!
Going to sleep...
Waking up...

0: Hello World!
Going to sleep...
Waking up...
_______________________________________________
unix-porting mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/unix-porting
Do not post admin requests to the list. They will be ignored.



References: 
 >pthreads and errno (From: "Scott D.W. Rankin" <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.