Opening 3 jobs in ash with i.e.

```
sh & sh & sh &

```

and counting this jobs with i.e.

```
jobs -p | wc -l

```

shows

```
3

```

which is OK.
But trying to assign this job count to a variable with

```
JOBNR=$(jobs -p | wc -l)

```

and printing this variable with

```
echo $JOBNR

```

shows

```
0

```

Why? Maybe during the assignment a new Shell (without jobs) was opened?
What could be the best solution?

Thanks in advance.