Question: I wanted to create a python virtual environment in Windows 7.
I have installed activepython 2.7 32 bit version and installed virtualev using pip command. After that I created a folder named "virtualenv", on drive C. For that folder I have executed the following command.

```
virtualenv <virtualenv-name>

```

While executing this command it opens a python file named `virtualenv.py`. While closing the file, it does not prompt to be saved.

While checking on `C:\virtualenv\` I was not getting the virtual environment that I tried to create.

Answer: 
This code gives the right exit code, and kills the survivor process:

```
#/bin/bash

# trap for SIGTERM and set RET_VALUE to false
trap "RET_VAL=false" SIGTERM

MY_PID=$$
# Initialize RET_VALUE to true
RET_VAL=true

# This function will executed be in a separate job (see below)
thread_listener() {
    # Starts the long time job 
    ./longJob.sh &
    PID=$!
    # trap for sigterm and kill the long time process
    trap "kill $PID" SIGTERM
    echo waiting for $PID
    echo Parent $MY_PID
    # Send a SIGTERM to parent job in case of failure
    wait $PID || kill $MY_PID
    exit
}

echo $MY_PID

# Runs thread listener in a separate job
thread_listener &
PID1=$!

# Runs thread listener in a separate job
thread_listener &
PID2=$!

wait
# send sigterm to PID1 and PID2 if present
kill $PID1 2> /dev/null
kill $PID2 2> /dev/null
# returns RET_VALUE
$RET_VAL

```

See the comments for an explanation of the code.
The trick is to starts jobs able to accept or send signal to parent job if needed. 

The child job send a signal to the parent in case of a failure of its long time job and the parent send a signal to its childs after the wait (it the parent receive a signal the wait returns immediatly)
The recent versions of GNU Parallel have focused on exactly that problem. Kill running children, if a single one fails:

```
parallel --halt now,fail=1 'echo {};{}' ::: true false true true false

```

Kill running children, if a single one succeeds:

```
parallel --halt now,success=1 'echo {};{}' ::: true false true true false

```

Kill running children, if 20% fails:

```
parallel -j1 --halt now,fail=20% 'echo {#} {};{}' ::: true true true false true true false true false true

```

Kill the child with signals TERM,TERM,TERM,KILL while waiting 50 ms between each signal:

```
parallel --termseq TERM,50,TERM,50,TERM,50,KILL -u --halt now,fail=1 'trap "echo TERM" SIGTERM; sleep 1;echo {};{}' ::: true false true true false

```