shutdown

What happens if System.exit is called from a shutdown hook?

喜欢而已 提交于 2019-12-09 15:00:14
问题 I have a rather complicated shutdown in Java - there's a lot of clean up work to do. In particular I'm trying to figure out how to error handle from a shutdown hook thread. My code includes this currently: try { return shutdownPromise = doShutdown(); } catch (Throwable exc) { logger.error("An exception was thrown while shutting down the application.", exc); System.exit(1); return null; } When I originally wrote this I essentially thought, an error in shutdown should just go straight to exit .

Should I process WM_ENDSESSION, WM_QUERYENDSESSION, both or neither?

僤鯓⒐⒋嵵緔 提交于 2019-12-08 21:05:39
If a system is trying to shut down, an app can block this shutdown by overriding OnQueryEndSession() and returning FALSE . Surely that means WM_ENDSESSION is the only definitive message to respond to regarding shutdown. On the other hand, the top answer to this question quotes no less than Raymond Chen as saying that responding to WM_ENDSESSION is essentially pointless. So this is confusing. Is there some kind of "best practice" principles to apply in deciding which of these messages (if any) one should respond to for doing what kinds of application shutdown work? In particular, if neither

aborting computer shutdown from windows service

余生长醉 提交于 2019-12-08 08:14:32
问题 Is it possible to abort computer shutdown from windows service? 回答1: Yes. You can call shutdown /a using Process.Start static void Main(string[] args) { Process p = new Process(); p.StartInfo.FileName = "shutdown"; p.StartInfo.Arguments = "/r"; p.Start(); Thread.Sleep(5000); p.StartInfo.Arguments = "/a"; p.Start(); } The above code tells the computer to shutdown and restart, waits 5 seconds, then aborts it. 回答2: AbortSystemShutdown I've added a sample to my answer at the similar question here

Auto Logoff of ms Access

时光毁灭记忆、已成空白 提交于 2019-12-08 07:24:51
问题 I manage an access database that runs on a server and utilizes the split tables and front end option. When i have to make updates i have to get everyone out of the database and this often is difficult. There is always one or two peopl who forget to log off after hours or dont exit when requested. I found a few third party access applications that say they work but i cant find any for access 2010. i guess in access 2010 they changed how user permissions work and this messes up the previous

Finding Which Program Runs Another

社会主义新天地 提交于 2019-12-08 02:34:29
问题 I have an NAS running on a limited version of what appears to be Redhat Linux. I followed directions to hack it so I could have shell access, which has been a big help. I've also made a couple modifications, ones that others have done and, other than one issue, they all seem to work fine. Somehow, every 22 days, the system shuts down. I used a script running ps to find that shutdown is actually called, but I don't know what program calls shutdown. If I rename /sbin/shutdown, then I could

Preventing Exceptions without Stack Frames with Error Exception Handler and Shutdown Sequences

允我心安 提交于 2019-12-08 02:34:13
问题 I've run over a somewhat little problem over the week. The error message upfront this is about: [30-Dec-2012 15:19:32] PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0 I think it is because my error handler (see below for details) is turning any error into an exception. I might should prevent that in case there is no stack frame. Is there an easy way to find out if there is any stack frame or not in PHP? Details: On one of my websites I've got an error handler

Shutdown Remote Computer in Java- Cannot initiate shutdown but no errors

浪子不回头ぞ 提交于 2019-12-08 01:46:39
问题 I am learning about the Runtime class in java, and am testing the use of command line instructions in it. I am trying to remotely shutdown a computer using Runtime.getRuntime().exec(...); When I run this, there are no errors, but the specified machine does not shut down. I don't know why. Code: import java.io.IOException; class shutdownVirus { public static void main(String[] args) throws IOException { Runtime.getRuntime().exec("shutdown -m \\\\T12-LEOPARDIJ -s -t 10"); } } Any help will be

Is there something like a ServletContextListener in JSF?

早过忘川 提交于 2019-12-07 19:36:33
问题 I would like to listen if a JSF application is started or stopped like as possible with a ServletContextListener in a plain Servlet web application. How can I achieve this? 回答1: You can use an @ApplicationScoped @ManagedBean which is eagerly initialized and annotate the desired startup/shutdown hook methods with @PostConstruct and @PreDestroy respectively. So: @ManagedBean(eager=true) @ApplicationScoped public class App { @PostConstruct public void init() { // ... } @PreDestroy public void

Why can race condition in LogWriter cause the producer to block? [Concurrency in practice]

我只是一个虾纸丫 提交于 2019-12-07 12:36:49
问题 First of all to prevent mark question as duplicate by guys who don't like read to the end I have read Producer-Consumer Logging service with Unreliable way to shutdown question. But it is not fully answer the question and answer contradicts the book text. In book provided following code: public class LogWriter { private final BlockingQueue<String> queue; private final LoggerThread logger; private static final int CAPACITY = 1000; public LogWriter(Writer writer) { this.queue = new

List<Runnable> returned from shutdownNow() can not be converted to submitted Runnable

两盒软妹~` 提交于 2019-12-07 12:00:54
问题 Below is the source code of the class. I wanted to verify how does shutdownNow() works for not submitted task. Problem I am getting in below code is shutdownNow() return List<FutureTask> and not List<Runnable> which I have submitted List<Runnable> containing submitted instance of PrimeProducer . In Below program I wanted to get the tasks which where not executed and their state so that I can reschedule them later. name() represents just state that I want to store. So I am not able to convert