access bash from C program?

2008-06-02 Thread Labitt, Bruce
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 KR 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

Re: access bash from C program?

2008-06-02 Thread Thomas Charron
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 KR at home... My googling has not particularly enlightened me, either... I'd like to run the equivalent of

Re: access bash from C program?

2008-06-02 Thread David J Berube
Come to think of it, it'd probably just be easier to run ulimit before you run the C program. David Berube Berube Consulting [EMAIL PROTECTED] (603)-485-9622 http://www.berubeconsulting.com/ Thomas Charron wrote: On 6/2/08, Labitt, Bruce [EMAIL PROTECTED] wrote: I've been scratching my brains

Re: access bash from C program?

2008-06-02 Thread Ben Scott
On Mon, Jun 2, 2008 at 11:19 AM, 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? The system(3) standard library function will let you pass a command to the OS for it to run.

Re: access bash from C program?

2008-06-02 Thread Bruce Dawson
One usually uses the 'system(3)' function to execute shell commands. However, this probably won't work in your case because executing 'ulimit -s hard', will be executed in a subshell (because the system function works this way). You will have to use the ulimit function to change it for the

Re: access bash from C program?

2008-06-02 Thread Bill McGonigle
On Jun 2, 2008, at 12:11, Labitt, Bruce wrote: a=getrlimit; //save current setting ulimit// do what I want setrlimit=a // restore setting I think only sub-processes are going to be affected by your ulimit call, so I'm not sure the [get,set]rlimit are even

RE: access bash from C program?

2008-06-02 Thread Labitt, Bruce
-Original Message- From: David J Berube [mailto:[EMAIL PROTECTED] Sent: Monday, June 02, 2008 11:55 AM To: Thomas Charron Cc: Labitt, Bruce; Greater NH Linux User Group Subject: Re: access bash from C program? Come to think of it, it'd probably just be easier to run ulimit before you run the C

Re: access bash from C program?

2008-06-02 Thread Steven W. Orr
On Monday, Jun 2nd 2008 at 11:54 -, 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

Re: access bash from C program?

2008-06-02 Thread Michael ODonnell
If I understand the requirements all you need to do is feed the appropriate ulimit command to the same instance of bash that ultimately executes the program you're trying to run, right? One simple approach sketched in pseudo-C would be: system( /bin/bash -c 'yourUlimitCommandHere ;

Re: access bash from C program?

2008-06-02 Thread Thomas Charron
On 6/2/08, Labitt, Bruce [EMAIL PROTECTED] wrote: That is what I do now. I was wondering if there was a programmatic or more elegant way... The way that has been suggested would be roughly a=getrlimit; //save current setting ulimit// do what I want setrlimit=a

Re: access bash from C program?

2008-06-02 Thread Thomas Charron
On Mon, Jun 2, 2008 at 11:19 AM, 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 KR at home... My googling has not particularly enlightened me, either... I'd like to

RE: access bash from C program?

2008-06-02 Thread Labitt, Bruce
Yes, that is what I wanted to do. I ran out of stack when doing large FFTs. -Bruce -Original Message- From: Thomas Charron [mailto:[EMAIL PROTECTED] Sent: Monday, June 02, 2008 5:39 PM To: Labitt, Bruce Cc: Greater NH Linux User Group Subject: Re: access bash from C program? On Mon

Re: access bash from C program?

2008-06-02 Thread Thomas Charron
On Mon, Jun 2, 2008 at 5:40 PM, Labitt, Bruce [EMAIL PROTECTED] wrote: Yes, that is what I wanted to do. I ran out of stack when doing large FFTs. Ok, then yes. getrlimit and setrlimit will work, using RLIMIT_STACK as the resource parameter. -- -- Thomas