I need to write a bash script that starts a blocking process, then detaches from it so I can run some other commands that configure this running process, then reattach to the original process such that ctrl+c will kill it.
Specifically, this happens to be the Google Cloud PubSub emulator, so the bash script looks something like the following pseudocode:
# TODO: pubsub will block, but I need to detach from it so I can create topics.
gcloud beta emulators pubsub start --host-port=localhost:8086
python publisher.py myapp create topic1
python publisher.py myapp create topic2
# TODO: Now I need to reattach to the pubsub process.
Thanks to @Barmar's comments above, I have a working solution on MacOS:
screen -S pub_sub_emulator -dm gcloud beta emulators pubsub start --host-port=localhost:8086
python publisher.py myapp create topic1
python publisher.py myapp create topic2
screen -r pub_sub_emulator
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.