Installation.

If you have the source distribution, run `make install'. If you have the Installer package (noposix-x.x.pkg), just install.

This copies the library "libnoposix.a" to "/usr/local/lib" and the "noposix.h" header file to "/usr/local/include". These directories are in the search path of the compiler, so if you want to use these routines all you have to do is link with "-lnoposix". Order is important, so -lnoposix is normally the last item on the command line.

Use.

Include the header file "noposix.h" in your sources. Compile and link your sources with -posix. Link with -lnoposix. All your calls to open, close, read, write, creat and lseek are covered.

If you generally want to switch between POSIX and non-POSIX mode, call:

_RnA_setposix( int newstatus)

where newstatus is 1 for POSIX active and 0 for POSIX inactive. _RnA_setposix() returns the previous value of the POSIX setting. Note, that we do not know what consequences there are for most POSIX calls when you have disactivated POSIX. It is therefore advisable to keep the change as short in time as possible:
	int oldstatus;
	oldstatus = _RnA_setposix( 0);
	/* some code, e.g. fopen() */
	_RnA_setposix( oldstatus);
This is still not completely100% safe, as interrupts may turn up before the POSIX status is reset. If you are paranoid or you seem to run into problems, you could temporarily disable all signals before turning POSIX temporarily off. On the other hand, we do not know of POSIX functionality like signalling stuff that doesn't properly work with POSIX turned off in the kernel (it seems to be kernel-independent).

The noposix library comes with replacements for low level I/O functions creat, open, close, write, read and lseek, these function are automatically wrapped when noposix.h is included in the file, unless NOPOSIX_QAD is set before inclusion of noposix.h.

Description

When people want to use posix functionality, but want to prevent the bugs in NeXT's POSIX implementation to harm them, they often have to do quite complicated things. To be able to compile for POSIX. they normally have to compile with -posix. This sets preprocessor flags and links against the posix library.

Sadly, though, NeXT's kernel contains a broken POSIX implementation. The worst affected is the low-level I/O, where everything you write in append mode is turned into 0-bytes. For most software, this makes POSIX unusable.

With noposix, there are two ways of getting around this bug.

The quick-and-dirty way (and the fastest in terms of execution) is like this. You include noposix.h and as a first call in the main function turn it off.

#define NOPOSIX_QAD
#include <noposix.h>

......

main()
{
#if defined( _POSIX_SOURCE) and defined( __NeXT__)
    _RnA_setposix( 0);
#endif;

	....
}

This is more or less the preferred way, because it also might catch other bugs in the posix implementation. The less quick-and-dirty only works when you use low level unbuffered I/O and you have full control over the sources. In that case, you just include noposix.h like this:

#include <noposix.h>

main()
{
	.....
}

The advantage is that POSIX is only turned off when I/O is used. This feels safer as we haven't turned posix off in the kernel while using posix stuff, like signals. On the other hand, we haven't noticed any ill effects from turning posix off in a posix program so far. But there is no warranty.

So if your program starts to behave funny with the first method, try the second.

No Warranty

There is no warranty whatsoever when using this software, as it is experimental and based on NEXTSTEP internals beyond our control.

November 27, 1997
Gerben Wierda