errno issues.

Godmar Back kaffe@rufus.w3.org
Sun, 23 Aug 1998 19:28:33 -0600 (MDT)


> 
> Hi!
> While trying to create a threadsystem that works on AmigaOS, I realized that the errno value isn't preserved
> when between processes.
> I know that the possibility is quite small that there is a context switch just when an IO function returns
> and the calling function reads errno, but it is there.
> 
> Any ideas anyone?
> 
> On those systems where errno is an external int errno, it shouldn't be more complicated than saving
> it during the context switch and restoring it afterwards, but what to do on those systems where
> errno is a macro?
> 

 Instead of making errno a thread-local variable, which is what you seem
to be suggesting, I think it would be better to make the functions that form 
the syscall interface thread-safe.  I.e., instead of 
	int read(int, void *, size_t)
use
	int read(int, void *, size_t, size_t *actual)
that returns 0 on success and errno otherwise.

	- Godmar