exit

VS2008 unit tests - assert method exits

非 Y 不嫁゛ 提交于 2019-12-12 08:54:13
问题 I'm trying to write a C# unit test with VS 2008's built-in unit testing framework and the method I'm testing calls Environment.Exit(0) . When I call this method in my unit test, my unit test is Aborted. The method should indeed be calling Exit , and I want a way to test that it does, and also to test the exit code that it uses. How might I do this? I looked at Microsoft.VisualStudio.TestTools.UnitTesting Namespace but didn't see anything that looked relevant. [TestMethod] [DeploymentItem(

What can cause Java to keep running after System.exit()?

最后都变了- 提交于 2019-12-12 07:44:43
问题 I have a Java program which is being started via ProcessBuilder from another Java program. System.exit(0) is called from the child program, but for some of our users (on Windows) the java.exe process associated with the child doesn't terminate. The child program has no shutdown hooks, nor does it have a SecurityManager which might stop System.exit() from terminating the VM. I can't reproduce the problem myself on Linux or Windows Vista. So far, the only reports of the problem come from two

Tomcat shuts down on closing jar

大憨熊 提交于 2019-12-12 06:59:47
问题 I made a java web application that calls a main method from a jar file i included as a WebAppLibraries and when this main calls system.exit to terminate it shuts down also the web app closing tomcat. How can avoid to shut down the web app closing only the execution of that main method? 回答1: By not calling System.exit(). Instead, call the appropriate API for shutting down web-apps for your container, which is container-specific. System.exit() isn't it. See the Javadoc. It's for shutting down

Exit a function within *apply

◇◆丶佛笑我妖孽 提交于 2019-12-12 05:39:52
问题 sapply and replicate (etc.) run a specified number of times. Putting sapply(1:N, function(n){expr}) will execute expr N times. Supposing I wanted sapply to stop after m runs. Is this possible without making an error? break doesn't work, and a for or while loop would be too slow in my context. Something akin to: sapply(1:N, function(n){ #some expression if(identical(n, m)) break }) except that break doesn't work. What I'm trying to do: Creating a function to read in large (binary) data files

Forked child exits with -1, but WEXITSTATUS gets 255

拜拜、爱过 提交于 2019-12-12 04:36:20
问题 I exit with -1 in the child, but the parent picks up 255 instead. Is there a way to make the parent recognize -1 instead? Here is my code pid = fork(); // if fork fails if (pid < 0){ exit(EXIT_FAILURE); } else if (pid == 0){ // purposely exit _exit(-1); } else{ int status; int corpse = wait(&status); if (WIFEXITED(status)) { int estat = WEXITSTATUS(status); if (estat == 0){ printf("Command was successfully executed\n"); } else{ printf("Error: child exited with status %d\n", estat); } } else

How to escape from for … each loop and method at the same time?

 ̄綄美尐妖づ 提交于 2019-12-12 03:57:15
问题 I am using the code below, that iterating over select options. I checked if options value has already entered. It escapes from for-each but it doesn't exit from method. yeniIlacBagla_ilacBagla: function(){ $("#bagliIlaclar > option").each(function(){ if(this.value===$("#baglanacakIlacID").val()){ alert($("#baglanacakIlacAdi").val()+'\n adlı ilaç zaten bağlıdır!'); return; }else{ $("#bagliIlaclar").append($('<option></option>').val($("#baglanacakIlacID").val()).html($("#baglanacakIlacAdi").val

Media Player streaming, when Exit app music should stop

狂风中的少年 提交于 2019-12-12 01:53:53
问题 I currently have a mediaplayer streaming some mp3 files. What I would like to do is if the User presses the home button to exit the app, the music stops playing. how would I go about doing this? 回答1: In your app' onPause() or onDestroy() call mediaPlayer.stop() . 回答2: @Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_HOME)) { Log.d(this.getClass().getName(), "home button pressed"); } return super.onKeyDown(keyCode, event); } Something like this

Using exit() in destructor of a class having static object, doesn't end up in an infinite loop as expected

陌路散爱 提交于 2019-12-11 23:43:41
问题 I came across this in chapter 10, Thinking in C++ vol.1 by Bruce Eckel. Destructors for static objects (that is, all objects with static storage, not just local static objects as in the example above) are called when main( ) exits or when the Standard C library function exit( ) is explicitly called. In most implementations, main( ) just calls exit( ) when it terminates. This means that it can be dangerous to call exit( ) inside a destructor because you can end up with infinite recursion I

Exiting c# app from splash screen

浪子不回头ぞ 提交于 2019-12-11 20:39:17
问题 I am using a splash screen for a c# which runs on startup and checks the app license. I show the splash from the main form like this: public partial class Form1 : Form { static bool stopThreads = false; static bool gridChanged = false; public Form1() { InitializeComponent(); Thread th = new Thread(new ThreadStart(DoSplash)); th.Start(); th.Join(); } private void DoSplash() { Splash sp = new Splash(); sp.ShowDialog(); } Now from the splash form I am trying exit the application when the license

return two values from perl to bash variables

折月煮酒 提交于 2019-12-11 19:22:02
问题 I am calling a perl script to calculate size and variation in bash script. Is there a way to return those two values to separated variables in bash, say $SIZE and $VAR. Only know how to return one value. 回答1: Instead of returning (which is mainly used for an error/success code from the script), you can print your variables from the perl script, separated by, say, space, and then read them from bash: #!/usr/bin/perl $size=1; $var=2; print "$size $var\n"; and: #!/bin/bash read SIZE VAR <<<$(my