Improve company productivity with a Business Account.Sign Up

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 204
  • Last Modified:

How can I "set process group" at the shell level

Is there anyway at the shell level to start multiple background processes, each one in its own process group?
  • 3
  • 3
1 Solution
Running ksh or csh, background task are all in their own process group, its the way job control works.

What shell are you using?
zebadaAuthor Commented:
I understand what it's for I just want to know if I can prevent it.

I know I can write a small C program to fork() and setpgrp() and spawn processes that way but I thought it would be easier to do via the shell if it is possible

I'm using ksh or csh I don't mind. (On HPUX and Tru64)

I have an application that is started multiple times by a single shell script. These processes serve up html. The program has a "bug" in that if the server gets a SIGSEGV, it will re-send a SIGSEGV to all other servers in its process groups like this:

if ( sig==SIGSEGV )

I have removed this "stupid" piece of code but until the app can be redeployed on site I need some way to prevent a rogue process from taking out ALL the other web servers.

Any ideas?
By default interactive ksh's start put background jobs in a fresh process group, if the your running from s shell script, turn this feature on using
  set -m
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

zebadaAuthor Commented:
Yes, but this doesn't help me. Interactive ksh does put background processes in a "fresh" process group - meaning that the process group is different from the ksh process - but the process group is still the same for ALL background processes.
The -m option just controls whether or not the background processes' process group id is the same as the shell or not.
Ok, hack it, do you need to maintain parent-child relationship with the foreground shell?  If not, maybe starting the other pipelines with eg.

  ksh -m -c "command | command &" &
No comment has been added lately, so it's time to clean up this Topic Area.
I will leave a recommendation for this question in the Cleanup topic area as follows:

- Answered by ecw

Please leave any comments here within the next 7 days


tfewster (I don't work here, I'm just an Expert :-)
zebadaAuthor Commented:
Sorry I didn't get back to this q.
-m did the trick :)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now