Operating System - HP-UX
1832995 Members
2240 Online
110048 Solutions
New Discussion

Problem in EXEC system call

 

Problem in EXEC system call

Hi ,

I' ve encountered a strange problem while using the exec() system call.
The description of the problem is as follows:

We are using "execl()' system call to load program B in the process space to replace the current program A.
This call is executed successfully and the program B starts executing in the place of the program A.
Now at the end of the program B we again want to return back to program A and hence we again use execl() to load program A.
At this point of time "execl" system call fails and errno is set to "ENOMEM" i.e. Not Enough Memory.
The size of the program A is 425 KB and that of program B is 45 KB.
Is there any way to retain the process space even if the new program is less than size of the previous program ???

Another imp observation is that the same process of using execl goes successfully when we do execl between program A and program C.
The size of the program C is 216 KB.

Can you give me some pointers in this problem ???

Thanks
It Has Been...
2 REPLIES 2
Ravi_8
Honored Contributor

Re: Problem in EXEC system call

have u used free() at the end of program B
never give up
A. Clay Stephenson
Acclaimed Contributor

Re: Problem in EXEC system call

Never seen this one before and it's very strange. What OS and compiler are you using?

I think I would try the other variants of exec
(execle,execlp,etc.).
Another workaround might be to
Use system in Program A to call program B and then when you exit B; A is where you left it.

These sizes you are giving us - what are they?
If they are the size of the executable that means almost nothing other than a hint at the size of the text section. Use glance, top, or a ps -l to get a better idea of the total program size.

I think with a little more data we can pin this one down. After all, the shell and processes spawned under it has to do exactly what you are doing.

Just some food for thought, Clay
If it ain't broke, I can fix that.