This is a discussion on How to programmatically set EXTSHM=ON for shmat() within the AIX Operating System forums, part of the Unix Operating Systems category; --> Hi, I am looking for a way of setting EXTSHM=ON programmatically (in C) such that it is recognised by ...
| |||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| Hi, I am looking for a way of setting EXTSHM=ON programmatically (in C) such that it is recognised by shmat() calls in the same process (yes I know it can be set in the environment at the shell level, but I don't want to do that, I want it built into the application, library etc.). I am using AIX 5.x. (see the shmat() man page for information about the effect of setting the environment variable EXTSHM) Simply coding a 'putenv("EXTSHM=ON")' only works for a subsequent shmat() call if there is an exec() call after the putenv(). One kludgy way I have found (for a simple application) is to re-exec() the main() of the program with EXTSHM=ON set, but this technique is not suitable for hiding away in a library. Does anybody know of any other way? Thanks, Greg |
| |||
| gregn2211 wrote: > I am looking for a way of setting EXTSHM=ON programmatically (in C) > such that it is recognised by shmat() calls in the same process (yes I > know it can be set in the environment at the shell level, but I don't > want to do that, I want it built into the application, library etc.). You can't. It takes effect at exec time, and by then it's too late. You either set it in your shell, or use putenv/exec, or use a shell script wrapper for your application. No other options. > the main() of the program with EXTSHM=ON set, but this technique is not > suitable for hiding away in a library. Why on earth are you trying to hide on OS-level setting? If your code requires EXTSHM, document the requirement and get on with your life. |
| ||||
| Hi Gary, I just think the usage of this EXTSHM environment variable is kludgy, and the developers of AIX could have achieved the same thing in a much better way using an API or maybe even a linker option etc. (considering that EXTSHM has performance ramifications and setting it can actually break existing applications). Other UNIXes dont have such a restriction on the number of shared memory segments used by an app, and even if they did, they certainly wouldn't control it using an environment variable. That's why I am trying to hide it, because I dont want to have the requirement that some stupid environment variable be set prior to running the software, the software should be able to set it itself. Obviously a shell script wrapper is OK for confining the setting to a particular application, but if you are just writing a plugin library to an existing application, then that's not really an option. Anyway, thanks for your input. At the least, I can check if EXTSHM is not set, and issue an error message. Greg |