Say I have two bash scripts (`p1.sh` and `p2.sh`), representing two programs:

```
#!/bin/bash

echo "hello"
sleep 10s
echo "good morning"
sleep 10s
echo "goodbye !!"

```

And `p2.sh`:

```
#!/bin/bash

# listen to the output of p1's program
# if p1 gives "goodbye !!" output, echo "p1 said goodbye!"

```

The workflow is:

1. Run `p1.sh`
2. Get the pid of the `p1` program
3. Let `p2.sh` listen to the `p1` process's output (instead of calling `p1.sh` inside of `p2.sh`), and judge `p1`'s output.

How to realize it? Thanks!