linux - 如何在后台运行使用shell的linux应用程序?

标签 linux shell background-process

我有一个来自 C 程序的应用程序/二进制文件,默认情况下使用 shell 获取用户的输入。因此,当我使用 & 在后台启动应用程序时,它会自动停止,因为我无权访问该实现。当我运行这段代码时

iStatus = system("./flute-static -send -a232.0.0.1/6666 a.txt &");

它给出输出[1] 21970,即pid。

然后,如果我按另一个回车键,它会给出输出

[1]+  Stopped                 ./flute-static -send -a232.0.0.1/6666 a.txt

显然它无法发送数据。我该如何解决这个问题。请帮我。提前致谢。

最佳答案

您可以尝试nohup

iStatus = system("nohup ./flute-static -send -a232.0.0.1/6666 a.txt &");

Nohup的意思是:即使stty被切断也不终止该进程。

或者您可以使用屏幕

https://www.mattcutts.com/blog/a-quick-tutorial-on-screen/

关于linux - 如何在后台运行使用shell的linux应用程序?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26464263/

相关文章:

c++ - 组织跨平台的C/C++项目

linux - bash - 删除目录列表(包括它们的内容)

ios - 应用程序在后台时是否可以使用 NSFileManager 的 `copyItemAtURL:toURL:error:` 方法?

linux - CRON bash 执行结果不同于手动启动

php - UTF-8贯穿始终

linux - samb.conf : Where is the "security" parameter?

C 函数 read() 导致命令注入(inject)

bash - 如何使用 bash 脚本输出提交次数?

ruby - 识别哪个 sidekiq 进程属于哪个应用程序

iphone - 如何将 beginBackgroundTaskWithExpirationHandler 用于已在 iOS 中运行的任务