当任务管理器中的进程结束时,Chrome应用程序window.onClosed不会触发-Google Chrome [英] Chrome app window.onClosed not fired when process ended from Task Manager - Google Chrome

查看:146
本文介绍了当任务管理器中的进程结束时,Chrome应用程序window.onClosed不会触发-Google Chrome的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个chrome应用程序,我们通过响应其onClosed事件再次打开主窗口来保持打开状态.但是,当该过程从Google的Chrome任务管理器中结束时,不会引发此事件.为什么是这样?我们可以解决这个问题,以便保持应用程序打开状态吗?到目前为止,我只是在Windows上运行它.

We have a chrome app that we keep open by openning again the main window in response to it's onClosed event. However, this event is not raised when the process is ended from Google's Chrome Task Manager. Why is this? Can we get around this so that we can keep the app open? So far, I've just run this on Windows.

推荐答案

Chrome任务管理器使用低级系统功能来终止该过程,请参见源代码(

Chrome Task Manager uses a low-level system function to terminate the process, see the source code (1, 2).

  • 在Windows上,它是

    进程无法阻止自身终止.

    A process cannot prevent itself from being terminated.

    旧的新事物的引文(这是MS软件工程师的博客,颇有名气):

    A quote from The Old New Thing (it's an MS software engineer's blog, quite famous):

    最终,您必须确定哪一方胜出,Windows决定让用户控制他们自己的程序和数据,并让管理员控制他们自己的计算机.因此,用户可以杀死他们想要的任何进程(具有足够的特权),可以阻止任何程序窃取焦点,并且可以删除他们想要的任何文件(再次具有足够的特权).

    Eventually you have to decide which side wins, and Windows has decided to keep users in control of their own programs and data, and keep administrators in control of their own computer. So users can kill any process they want (given sufficient privileges), they can stop any program from stealing focus, and they can delete any file they want (again, given sufficient privileges).

    程序可以尝试使自己更难杀死(拒绝PROCESS_TERMINATE访问,拒绝PROCESS_CREATE_THREAD访问,这样人们就不能创建RemoteThread(EndProcess),拒绝PROCESS_VM_WRITE,这样人们就不能乱涂乱画到您的堆栈中并使您出现双重故障,拒绝PROCESS_SUSPEND_RESUME他们无法暂停您),但是最终您无法阻止他们升级到Debug特权,调试您的进程并将EIP移至"ExitProcess".

    Programs can try to make themselves more difficult to kill (deny PROCESS_TERMINATE access, deny PROCESS_CREATE_THREAD access so people can't CreateRemoteThread(EndProcess), deny PROCESS_VM_WRITE so people can't scribble into your stack and make you doublefault, deny PROCESS_SUSPEND_RESUME so they can't suspend you), but eventually you just can't stop them from, say, elevating to Debug privilege, debugging your process, and moving EIP to "ExitProcess".

    请注意,您可以根据需要杀死CSRSS.EXE和WINLOGON.EXE.您的计算机会很生您的气,但是您可以做到. (先保存您的工作!)

    Notice that you can kill CSRSS.EXE and WINLOGON.EXE if you like. Your computer will get very angry at you, but you can do it. (Save you work first!)

    另一个要问自己的有用问题:如何防止病毒做同样的事情?"如果有一种方法可以执行这些操作,则病毒可以利用它们并使自己对任务管理器不可见,不可删除且不可杀死.显然,您不想要那样吗?

    Another useful question to ask yourself: "What's to prevent a virus from doing the same thing?" If there were a way to do these things, then a virus could take advantage of them and make itself invisible to Task Manager, undeletable, and unkillable. Clearly you don't want that, do you?

  • 在Unix Chrome任务管理器上

  • On Unix Chrome Task Manager uses kill API function to send SIGTERM signal, which can be seen by the process, followed by unconditional SIGKILL (after some time):

    不能捕获,阻止或忽略信号SIGKILL和SIGSTOP.

    The signals SIGKILL and SIGSTOP cannot be caught, blocked, or ignored.

  • 这篇关于当任务管理器中的进程结束时,Chrome应用程序window.onClosed不会触发-Google Chrome的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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