On Monday, Jun 2nd 2008 at 11:54 -0000, quoth David J Berube:

=>Come to think of it, it'd probably just be easier to run ulimit before 
=>you run the C program.

It's not clear that you can do that (but you *might* be right anyways).

from man 2 fork:

       fork  creates a child process that differs from the parent process only
       in its PID and PPID, and in the fact that resource utilizations are set
       to 0.  File locks and pending signals are not inherited.

So it's not clear to me that an altered set of limits would be inherited. 

In addition, a C program would never be able to call something like 
system("ulimit...") and have it stick because the subprocess would just 
disappear leaving the parent unaffected.

So it looks to me like you either do it in your C program using setrlimit, 
or you write a script, a la

#! /bin/bash
ulimit...
exec myCprogram

The exec would keep the process mod in the process.



=>Thomas Charron wrote:
=>> On 6/2/08, Labitt, Bruce <[EMAIL PROTECTED]> wrote:
=>>> I've been scratching my brains here a bit.  Is there an easy way to get
=>>> access to the shell (bash) from within a C program?  I left my K&R at
=>>> home...
=>>> My googling has not particularly enlightened me, either...
=>>> I'd like to run the equivalent of the command "$ ulimit -s hard"
=>>> I need to do this because I need much more stack than the terminal
=>>> window ordinarily allows.  (Can't run FFTs > 256K without above
=>>> command.)
=>> 
=>>   See the ulimit() function?  Or getrlimit() and setrlimit()?

-- 
Time flies like the wind. Fruit flies like a banana. Stranger things have  .0.
happened but none stranger than this. Does your driver's license say Organ ..0
Donor?Black holes are where God divided by zero. Listen to me! We are all- 000
individuals! What if this weren't a hypothetical question?
steveo at syslang.net
_______________________________________________
gnhlug-discuss mailing list
gnhlug-discuss@mail.gnhlug.org
http://mail.gnhlug.org/mailman/listinfo/gnhlug-discuss/

Reply via email to