如何保护我的进程不被杀死? [英] how to protect my process from being killed?

查看:573
本文介绍了如何保护我的进程不被杀死?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们在Linux上有一个关键任务服务器程序,我们不希望其他人意外终止它.如果有人将其终止或崩溃,我们希望它重新启动.

We have a mission-critical server program on top of Linux and we don't want others to terminate it accidentally. If somebody terminates it or it crashes, we want it to restart.

因此,我们计划编写另一个程序,例如程序B.我们希望程序B和服务器程序相互保护.如果我们的服务器程序退出,程序B将重新启动它.如果程序B终止,则服务器程序将再次启动它.但是,我们没有一种好的机制可以让程序B和服务器程序在其对等项退出时得到通知.

So we plan to write another program, say program B. We want program B and the server program to protect each other. If our server program exits, program B will restart it. If program B terminates, the server program will start it again. But we don't have a good mechanism that would let program B and the server program be notified when its peer exits.

推荐答案

您可以使用init来照看该进程,并且由于init仅在重新启动时终止,因此您不需要程序B".

You can use init to babysit the process, and since init only terminates on reboot, you don't need a "program B".

添加到/etc/inittab的末尾:

Add to the end of /etc/inittab:

x:3:respawn:/path/to/my/program

有关语法和其他选项的信息,请参见man inittab

For information on syntax and other options can be found in man inittab

这篇关于如何保护我的进程不被杀死?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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