execv() terminates a program

execv() terminates a program

Post by Evgeny Baskak » Sat, 28 Jun 2003 20:28:25



I have a program that uses threads (Linux, pthread 0.10).
One thread asks to another one, called "Forker", to execute an
application, given by a filename. The Forker thread calls fork()
function and then the child process calls execv() function.

Regardless of expectation, the application not starts, and my
program immediately terminates with 0 exitcode.

I not understand a thing. Someone can explain me this strange
bahavior?

Excuse my English, please.

I will be very grateful for any help.

 
 
 

execv() terminates a program

Post by Jens.Toerr.. » Sat, 28 Jun 2003 20:38:18



> I have a program that uses threads (Linux, pthread 0.10).
> One thread asks to another one, called "Forker", to execute an
> application, given by a filename. The Forker thread calls fork()
> function and then the child process calls execv() function.
> Regardless of expectation, the application not starts, and my
> program immediately terminates with 0 exitcode.

Which program? The child process?

Quote:> I not understand a thing. Someone can explain me this strange
> bahavior?

Unless you post the code you use with the execv() call that's
hardly going to be possible. First guess is you're making some
mistakes there, but without seeing what you do it's impossible
to tell.
                                    Regards, Jens
--
      _  _____  _____

  _  | |  | |    | |
 | |_| |  | |    | |          http://www.physik.fu-berlin.de/~toerring
  \___/ens|_|homs|_|oerring

 
 
 

execv() terminates a program

Post by agrawal » Sat, 28 Jun 2003 21:00:14


i guess due to some error in code the memory is getting overwritten and
hence program terminates.

as told, it will be good if you can paste part of the code.


Quote:> I have a program that uses threads (Linux, pthread 0.10).
> One thread asks to another one, called "Forker", to execute an
> application, given by a filename. The Forker thread calls fork()
> function and then the child process calls execv() function.

> Regardless of expectation, the application not starts, and my
> program immediately terminates with 0 exitcode.

> I not understand a thing. Someone can explain me this strange
> bahavior?

> Excuse my English, please.

> I will be very grateful for any help.

 
 
 

1. Terminating parent vs terminating children

Hello all,

Consider the following situation:

A parent process allocates a set of semaphores. It then begins to
spawn children (which use the semaphores). The semaphores are
a global resource and so need to be explicitly destroyed; however
if a *child* process destroys them accidentally then things could
get nasty. So the question becomes: where is the best place to
clean up?

There seem to be two places to put cleanup code: in exit
procedures, which are installed using atexit(), and in signal
functions. In the code that I am patching, the signal functions
for SIGTERM, SIGTRAP, SIGQUIT and SIGINT etc all call
exit() and so atexit() would seem like a good idea. However,
I think I am correct in saying that both signal handlers and
exit procedures are inherited by child processes.

I *could* do the following:

int child_pid = -1;
atexit(MainCleanupProcess);
...
child_pid = fork();
if (child_pid==0)
{
  atexit(CleanupChildProcess);
  ...

with

void MainCleanupProcess(void)
{
  if (child_pid != 0)
  {
    /* destroy semaphores */
  }

but I can't shake the feeling that there is probably a better
way of doing this. Can anyone shed any light, please?
(Using portable UNIX...)

Thanks in advance,
Chris.

2. Cable Modems

3. Program terminates

4. TSM 3.7 and 3570 and 3575

5. Send causes program to terminate

6. REPOST: Install RH6.1 from Win95 partition?

7. cant load specfs program terminated

8. SYS V sigset(2)

9. dbx: Program terminated by signal trap

10. Installation program terminates "NOTICE: ram: No space on device on device 31/50"

11. `showrev -p` ==> Method program unexpectedly terminated with signal 11

12. How to call another program and terminate...

13. Program terminates