Unix Technical Forum

How to programmatically set EXTSHM=ON for shmat()

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


Go Back   Unix Technical Forum > Unix Operating Systems > AIX Operating System

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 01-05-2008, 09:18 AM
gregn2211
 
Posts: n/a
Default How to programmatically set EXTSHM=ON for shmat()

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 01-05-2008, 09:22 AM
Gary R. Hook
 
Posts: n/a
Default Re: How to programmatically set EXTSHM=ON for shmat()

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.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 01-05-2008, 09:24 AM
gregn2211
 
Posts: n/a
Default Re: How to programmatically set EXTSHM=ON for shmat()

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

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 11:40 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com