errno issues.

Godmar Back gback at cs.utah.edu
Sun Aug 23 18:28:33 PDT 1998


> 
> 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



More information about the kaffe mailing list