Reputation: 41
I have the following script, allowing me to port-forward containers from my kubernetes cluster and then start the UI locally.
kubectl port-forward --namespace default svc/gql-api-exposer 8080:8080 &
kubectl port-forward --namespace default svc/kratos-public 8090:80 &
yarn dev
The thing that confuses me is that the port-forwards do not keep running when I stop the script via ctrl-c. Why is this the case? Why don't I need something like trap 'pkill $(jobs -p)' EXIT
?
Upvotes: 0
Views: 135
Reputation: 695
By pressing Ctrl+C you are sending a SIGINT
to the process in foreground, which bash
will forward signal to the child processes.
You can mitigate that as following:
#using disown
command & disown
#using nohup
nohup command &
Upvotes: 1