Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5842093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T11:58:23+00:00 2026-05-22T11:58:23+00:00

I have a driver script which manages a job string which can run jobs

  • 0

I have a driver script which manages a job string which can run jobs in parallel or sequentially based on a dependency graph. For example:

Job              Predecessors

A                null
B                A
C                A
D                B
E                D, C
F                E

The driver starts A in the background and waits for it to complete by suspending itselfusing bash built-in suspend. On completion, job A sends a SIGCONT to the driver which would then start B and C in the background and suspend itself again, and so on.

The driver has a set -m so job control is enabled.

This works fine when the driver is itself started in background. However, when the driver is invoked in the foreground, the first call to suspend works fine. The second call seems to turn into an ‘exit‘ which reports a “There are stopped jobs” and does not exit. The third call to suspend also turns into an ‘exit‘ and kills the driver and all children [as it should considering this is the second converted call to ‘exit‘].

And this is my question: Is this expected behavior? If so, why and how do I work around it?

Thanks.

Code fragments below:

Driver:

            for step in $(hash_keys 'RUNNING_HASH')
            do
                    proc=$(hash_find 'RUNNING_HASH' $step)
                    if [ $proc ]
                    then
                            # added the grep to ensure the process is found
                            ps -p $proc | grep $proc > /dev/null 2>&1
                            if [ $? -eq 0 ]
                            then
                                    log_msg_to_stderr $SEV_DEBUG "proc $proc running: suspending execution"
                                    suspend 
                                    # execution resumes here on receipt of SIGCONT
                                    log_msg_to_stderr $SEV_DEBUG "signal received: continuing execution"
                                    break
                            fi
                    fi
            done

Job:

## $$ is the driver's PID
kill -SIGCONT $$
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T11:58:24+00:00Added an answer on May 22, 2026 at 11:58 am

    I have to think you are over-complicating things playing with job control and suspend, etc. Here is an example program which keeps 5 children running at all times. Once a second it looks to see if anyone went away (much more efficiently than ps|grep, BTW) and starts up a new child if necessary.

    #!/usr/bin/bash
    
    set -o monitor
    trap "pkill -P $$ -f 'sleep 10\.9' >&/dev/null" SIGCHLD
    
    totaljobs=15
    numjobs=5
    worktime=10
    curjobs=0
    declare -A pidlist
    
    dojob()
    {
      slot=$1
      time=$(echo "$RANDOM * 10 / 32768" | bc -l)
      echo Starting job $slot with args $time
      sleep $time &
      pidlist[$slot]=`jobs -p %%`
      curjobs=$(($curjobs + 1))
      totaljobs=$(($totaljobs - 1))
    }
    
    # start
    while [ $curjobs -lt $numjobs -a $totaljobs -gt 0 ]
     do
      dojob $curjobs
     done
    
    # Poll for jobs to die, restarting while we have them
    while [ $totaljobs -gt 0 ]
     do
      for ((i=0;$i < $curjobs;i++))
       do
        if ! kill -0 ${pidlist[$i]} >&/dev/null
         then
          dojob $i
          break
         fi
       done
       sleep 10.9 >&/dev/null
     done
    wait
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have established a link using Netbeans and Paradox driver and can query the
I have a PS/2 touchpad which I would like to write a driver for
I have a piece of USB hardware, for which I know the driver. However,
I am using Oracle 9 JDBC Thin Driver - the connection string I have
I have a device driver I want to patch. This device driver calls IOLog
I have a C++ driver I'm trying to compile, and it has this line
I'm developing a Linux driver loadable module and I have to use another device
I have a PHP-driven site that includes an XML stock feed, which is remotely
I have a project in which I'm accessing a MySql database on my web
I am making a Python script which will read in a GeoTIFF file, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.