BASH:发送SIGTSTP信号(ctrl + z) [英] BASH: send SIGTSTP signal (ctrl+z)

查看:77
本文介绍了BASH:发送SIGTSTP信号(ctrl + z)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我急于进行编程任务,其中我必须同时在同一台计算机上运行同一程序的多个实例.目前,我一次启动一个实例,按 Ctrl + z 暂停它们,然后执行'bg%#'在后台恢复执行.

I'm rushing against the clock for a programming assignment in which I have to run a number of instances of the same program on the same machine at the same time. Currently, I'm starting the instances one at a time, pressing Ctrl+z to pause them, and then doing 'bg %#' to resume execution in the background.

每次我需要测试应用程序中的小变化时,这都是非常繁琐且耗时的事情,因此我想编写一个bash脚本来为我启动多个实例,但是我不知道该如何做.在脚本中进行后台切换.

This is extremely tedious and time consuming to do every time I need to test a small change in my application, so I want to write a bash script that will start the multiple instances for me, however I don't know how to do the background switching in a script.

有人可以告诉我如何编写一个简单的脚本来启动一个长期存在的命令,将其暂停并在后台继续运行吗?

Can anybody please tell me how I can write a simple script that will start a long standing command, pause it, and resume it in the background?

谢谢

推荐答案

您是否只想在后台启动?例如:

Do you want to just start it in the background? For example:

mycommand &

如果您想要更细粒度的作业控制,则可以模拟 Ctrl - Z bg . Control - Z SIGTSTP ("tty stop")发送到程序,该程序将暂停:

If you want finer grained job control, you can emulate Ctrl-Z and bg. Control-Z sends SIGTSTP ("tty stop") to the program, which suspends it:

kill -TSTP [processid]

bg 命令只是向其发送 SIGCONT :

kill -CONT [processid]

这篇关于BASH:发送SIGTSTP信号(ctrl + z)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆