SVR4 or BSD?

Can we determine (reliably or guaranteed) at runtime if a system is SVR4 or BSD based, using two methods, shell and binary (C code)?

20 years ago the unix world was divided into two camps: USG (Unix Support Group) which includes stuff like System III and all of the various System V's and BSD (Berkeley Software Distribution) which was the various Berkeley releases. That hasn't been true for a long time.

A pure SVR4 system is actually rather rare. NetBSD and FreeBSD are stronger, but most versions of Unix have combinations of feature from both camps. SunOS and HP-UX are the commercial versions of unix with the largest market share. Linux is the free version of unix that is most widely used. None of these 3 OS's can be said to be SVR4 or BSD.

The thing to do these days is to test feature by feature. Also most versions of Unix support Posix so you can restrict yourself to those things that Posix defines and have a pretty good shot at working.

A pure BSD system will have the select() system call. A pure SVR4 system will have the poll() system call. HP-UX and SunOS support both. Most things are like that.

But to answer your question, in case you really have a shop that has only BSD and SVR4...

In C you used to stuff like:

#ifdef USG
Note that this is done at compile time, not at runtime.

In a shell script, inspect the output of from the uname command, and this can be done at runtime.

Thanks for the reply.

I was looking for confirmation of the difficaulty because of merged features, I know of the poll/select difference and have seen scripts that check for certain directory structures but have never seen anything conrete.

Thanks again, as always it's never a straightforward answer :slight_smile: