UNIX Socket FAQ

A forum for questions and answers about network programming on Linux and all other Unix-like systems

You are not logged in.

  • Index
  • » Processes
  • » Problem in executing an operation in child process

#1 2006-11-29 03:05 PM

shiva
Member
From: INDIA
Registered: 2002-08-10
Posts: 94

Re: Problem in executing an operation in child process

I have a process running as child, which in turn forks and execute a system call "system" to create a tar file. This never happens and found using truss this process receives SIGALRM signal and hangs from this point onwards.This job never executed.Often I receive interrupted signal EINTR also.

The same problem observed if we execute with system call execv.
I stopped the SIGALRM signal using alarm(0) before forking the process.
The problem still persists.

|--->Parent process
   |
   |--> My process
      |
      |---> Process to execute tar command using system/execv call

But when I run this job as parent process this tar file created successfully.

   |--> My process (Parent process)
      |
      |---> Process to execute tar command using system/execv call

I hope the problem is explained in an understanble way.
Let me know what/where could be the problem.

Thanks in advance

-Shiva

Offline

#2 2006-11-29 09:00 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: Problem in executing an operation in child process

Are you using alarm() anywhere in your code?  Or, anything similar which might
mess with SIGALRM, such as setitimer() or even sleep() on some platforms?
The alarm(0) should indeed cancel any outstanding alarm's from alarm(), so I'm
guess it'd have to come from some other source...  Depending on what is doing
it exactly, maybe just try ignoring and/or blocking SIGALRM...  (If it's from sleep(),
then that probably won't help; but, then, if sleep() is doing it, it should also be
handling it, so it shouldn't be a problem for you...)

Oh wait, which process are you saying gets the SIGALRM?  Your child, or the
spawned "tar" process?  If the latter, then it must be something in the tar code
itself doing it...  Not sure what or why...  Just for the hell of it, have you tried
redirecting tar's stdin/out/err from/to "/dev/null"?  Maybe it's some weird
interaction with the controlling tty...  (Though, I wouldn't expect SIGALRM to be
the result in that case...  Maybe SIGTTIN/SIGTTOU/SIGTSTP or something...)

I don't know, it's kind of hard to speculate about what exactly might be going on
without code...  If you could strip the code down to the bare essentials which still
shows the problem, post it...  Then, we can try it ourselves, and try to find the
problem (if it's isn't immediately obvious to one of us)...

Offline

#3 2006-11-30 08:18 AM

shiva
Member
From: INDIA
Registered: 2002-08-10
Posts: 94

Re: Problem in executing an operation in child process

Offline

#4 2006-11-30 02:15 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: Problem in executing an operation in child process

Um, I don't see any reference at all to SIGALRM in that output...

Offline

#5 2006-11-30 02:51 PM

shiva
Member
From: INDIA
Registered: 2002-08-10
Posts: 94

Re: Problem in executing an operation in child process

Rob,

We have ignored the SIGALRM as well as modified the code to stop the alarm signal, but still we face the same problem.

Can you able to see a SIGPIPE being executed conitnously from a child process and there nothying happens...just hangs.....

Just have a look at the truss output per process wise which we have given.

-Shiva

Offline

#6 2006-11-30 03:48 PM

RobSeace
Administrator
From: Boston, MA
Registered: 2002-06-12
Posts: 3,847
Website

Re: Problem in executing an operation in child process

Yeah, your original message already said you used alarm(0), but claimed you were
still getting hit with SIGALRM...  As far as I was able to comprehend from your
message, THAT was what you were saying was your problem: getting SIGALRM...
But, you're now saying you no longer get SIGALRM, so in fact that was just a red
herring which had nothing at all to do with the real problem: which is simply that
the "tar" is not exiting?

Ok...  I see from that output that it looks like tar is getting a broken pipe writing to
FD 10 over and over...  I don't know what pipe it'd be writing to, though...  Is that
output tar file on an NFS mount or something?  If it's an actual local file its creating
on its hard drive, I sure wouldn't expect to see EPIPE/SIGPIPE...  Or, maybe FD 10
isn't really the output file, but something else it's trying to write to?  Do you have
"lsof" installed?  If so, try seeing if that can tell you what FD 10 refers to in that tar
process...  (If it's really the output file, I have no idea why tar would just keep blindly
trying over and over like that, rather than dying with a fatal error, anyway...)  I also
have no idea why it should make any difference whether you spawn tar from the
parent or child process of your server...  (Assuming they both use the same exact
command-line, anyway...)

Offline

  • Index
  • » Processes
  • » Problem in executing an operation in child process

Board footer

Powered by FluxBB