bash 如何在linux中通过init杀死重生的进程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21016641/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to kill respawned process by init in linux
提问by user2857290
am respawning the /bin/bash on ttyS1 port.ttyS0 is my console. inittab entry is given below.
我在 ttyS1 port.ttyS0 上重生 /bin/bash 是我的控制台。下面给出了 inittab 条目。
::respawn:/bin/bash < /dev/ttyS1 > /dev/ttyS1 2> /dev/ttyS1
::respawn:/bin/bash < /dev/ttyS1 > /dev/ttyS1 2> /dev/ttyS1
My question is how to disable/kill respwning so that i can use serial port for other application.
我的问题是如何禁用/终止重新生成,以便我可以将串行端口用于其他应用程序。
回答by leu
You can kill that bash process like other processes. However, init respawns it immediately - nothing gained.
您可以像其他进程一样终止该 bash 进程。然而, init 立即重生它 - 没有任何收获。
To disable the process you have to edit /etc/inittab and comment out that line.
To inform init about this change you have to send a SIGHUP to init: kill -HUP pid-of-init
.
(I think that pid-of-init is always 1).
要禁用该进程,您必须编辑 /etc/inittab 并注释掉该行。要通知 init 有关此更改,您必须向 init: 发送 SIGHUP kill -HUP pid-of-init
。(我认为 pid-of-init 总是 1)。
If you need your bash connected to ttyS1 in some circumstances you may want to specify certain runlevels in which init should start bash.
如果您在某些情况下需要将 bash 连接到 ttyS1,您可能需要指定 init 应在其中启动 bash 的某些运行级别。
Hope this answer helps... (see man inittab
for further information)
希望这个答案有帮助...(man inittab
有关更多信息,请参阅)
回答by Oleg Gryb
On my Ubuntu this is what worked for me:
在我的 Ubuntu 上,这对我有用:
sudo rm -f /etc/init/<proc_name>.conf
sudo initctl stop <proc_name>
It returned a message:
它返回了一条消息:
initctl: Method "Get" with signature "ss" on interface "org.freedesktop.DBus.Properties" doesn't exist
but the process was stopped anyway without respawning.
但该过程无论如何都停止了而没有重生。
回答by NiVer
inittab have to be reexamine otherwise it will launch the process. Delete the command line link to process on /etc/inittab and execute:
inittab 必须重新检查,否则它将启动该进程。删除命令行链接以在 /etc/inittab 上进行处理并执行:
# init q
or
或者
# telinit q
Then , you can kill the process and it will not respawn.
然后,您可以终止该进程并且它不会重新生成。