Elegant way of stopping a looping application?

Hi all!
What would be the best way to stop an application that works with a loop
(checking files every x seconds or listening on a TCP port for example).
I start the application using a shell script and kill it with it's process-ID.
Problem is if there are any database connections open I have no time left
to close them if I kill the VM.
Any suggestions for a 'clean' shutdown?

Killing it like that is by definition an abnormal termination, of course. You'll need to redesign the application so that it "knows" when it's time to quit. Maybe this isn't what you're getting at - this is basic stuff.
while (keepWorking)
  // do your stuff
  // if you get a message saying time to quit then set keepWorking = false
  // for example, if you're listening to a port, maybe something should send a "quit" message to the port
// program continues here, to clean up and exit

Similar Messages

  • What is the best way to stop parallel loops at the same time, from any loop?

    If there is a vi with two or more parallel while loops, what would be a good method to simultaneously stop parallel loop execution, from any of the parallel loops? My intent was to try and do this without local variables, so I used notifiers. This seems like an ok method for two loops, but how about for n loops?
    In addition, my code has a flaw. I use an OR block to compare the stop status of each of the loops. This works fine most of the time, but if both loops are triggered to stop at the same time,the boolean result will be false, causing the loops to never stop. How can this be avoided?
    Thanks,
    Curt
    Attachments:
    parallel_loop_w-stop.vi ‏54 KB

    I think you have the right idea, notifiers are one of the better ways to stop parallel loops. You can simplify things by using 1 notifier for everything. I modified your VI to use 1 notifier, it will set the notifier to True ONLY if the loop is stopping, then it stops. The other loop will read the notifier status, and stop based on it the next time it executes.
    I also changed the second loop to stop and notify if it has an error (that is usually a good idea, especally if you have I/O or other things that can cause problems)
    I also changed the switch mechanical action, that will eliminate the problems for your second question.
    The VI's attached are written in Labview 7.0
    P.S. If you have 7.1, the Queues are polymorphic, meaning that the typecast operat
    ions are NOT needed!
    Attachments:
    parallel_loop_w-stop7_0.vi ‏45 KB

  • Is there a way to stop the launching applications to come to foreground?

    Is there a way to stop the launching applications to come to foreground?
    Back with os 10.3 Panther or 10.4 Tiger the apps opened in the background. That was one of the good differences with Windows. I guess that 10.5 Leopard adopted this annoying Windows behavior. Hope it's gonna change with 10.7 Lion.
    (Of course I am looking for another solution than the AppleScript/Terminal launch that can be found on Google. I'd rather have a plist option to change if it exists!)

    I have found this page http://www.realsoftware.com/listarchives/realbasic-nug/2009-03/msg01167.html where it is proposed to add :
    <key>LSBackgroundOnly</key>
    <string>True</string>
    to MyApp.app/Contents/Info.plist
    I tried this but the app launches totally hidden in the background. Plus you have to set this behavior for every app.
    The open -g option works fine as expected.
    Still looking for a system-wide option, but it doesn't seem to exist.
    About the utility of such an option, I'll just remember you that some machine don't load apps very fast and, instead of waiting for an app to launch, the user will do something else until the app launches. You'll understand that waiting in front of a computer isn't acceptable and having a MBPro isn't possible for everyone.

  • Is there a way to stop all loops( While and For )at once or close the big application with just a button?

    How to sop all loops in the application (While, For and subvis ) with a single button? Use the event sturucture?

    Yes, if you just need to kill the running application, you can use an event structure in a parallel loop. (See attached code image). Pressing the stop button stops everything! :-)
    (Alternatively, you could even call "quit labview".)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    Killall.png ‏6 KB

  • Stopping Timed Loop inside a Reentrant VI

    I just converted a project over from 8.5 to 2009 and I found that some of the funtionality that was working in 8.5 no longer works in 2009 (probably for good reason...).
    Anyway, I found that if I tried to use the stop timed loop vi to stop any timed loops in reentrant vi's that I get a -804 error. The stop timed loop sub vi was in the same reentrant vi in the application, but I found it also did not work if it was outside the reentrant vi.
    It does get a little hairy when thinking which loop you are trying to stop because of the reentrancy, but if the names passed into the instances are different for the loops then it shouldn't be a problem right?
    See attached for a very simple example of this occuring.
    Note: Just running in windows...not in RT
    Solved!
    Go to Solution.
    Attachments:
    Stop Time Loop.LLB ‏41 KB

    I resorted to using an alternative way to stop the loops as well.  Does anyone at NI know if this is a feature or a bug or if there is anyway to use the stop timed loop function with a timed loop in a reentrant vi?
    Thanks.
    Whoops... Just read your post.  Thanks for the update.
    Message Edited by klessm1 on 01-06-2010 10:55 AM

  • Is there a way to stop flash player from looping on someone elses website?

    Is there a way to stop flash player from looping on someone elses website?
    The longer we have the site open the more memory it uses as flash continues to loop.

    how can i use flash player on my website http://howhut.com/ its a tutorial website and i want to use my own flash player instead of using embeded code from other video websites. Is there any way?

  • ITunes keeps 'quitting unexpectedly'- No way to stop it

    iTunes 11.1.3 on a Retina Pro MacBook running OSX 10.8.5 is totally broken.
    For some reason, iTunes has started to crash, flashing up a technical report that 'iTunes quit unexpectedly' (first part of the error report attached below).
    This error keeps repeating in a loop, closing and re-opening iTunes without me actually doing anything. It does this about once every 2-3 seconds (seriously!!) so it has flashed this error report up (which jumps to the forefront and prevents me doing anything useful on any other app) at least 40 times while I was typing this short message. ARGH!!
    The only way to stop this is to restart the MacBook (which is not easy because iTunes keeps cancelling the restart).
    Any ideas anyone? Has this been fixed anywhere?
    It's driving me nuts...
    Process:         iTunes [889]
    Path:            /Applications/iTunes.app/Contents/MacOS/iTunes
    Identifier:      com.apple.iTunes
    Version:         11.1.3 (11.1.3)
    Build Info:      iTunes-1113011001003008~1
    Code Type:       X86-64 (Native)
    Parent Process:  launchd [118]
    User ID:         501
    Date/Time:       2013-12-21 23:04:57.190 +0000
    OS Version:      Mac OS X 10.8.5 (12F45)
    Report Version:  10
    Interval Since Last Report:          41980 sec
    Crashes Since Last Report:           153
    Per-App Interval Since Last Report:  103273 sec
    Per-App Crashes Since Last Report:   73
    Anonymous UUID:                     
    Crashed Thread:  0  iTunes main  Dispatch queue: com.apple.main-thread
    Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x00007fff54994000

    Thanks...I had tried that but it creates all kinds of other inconveniences on a 13" screen. CHM

  • Starting and stopping a loop

    I am importing a list of 10,000 emails into memory and then
    comparing them to a database which holds over 400,000 records. It
    doesnt take long for the <cfquery> to time out. I know there
    must be a way to loop thru 20 or so, then stop, then loop thru the
    next 20, etc. I cannot lengthen the timeout so I need to figure out
    a way to process the data in chunks. Thanks.
    <cfhttp method="Get"
    url="
    http://192.168.14.51/matt/email.CSV"
    columns="Email"
    name="importCSV"
    delimiter="#chr(10)##chr(13)#"
    textqualifier="">
    <cfset counter = 0>
    <cfloop index="element" list = "#CFHTTP.FileContent#"
    delimiters="#chr(10)##chr(13)#">
    <cfset counter = counter +1>
    </cfloop>
    <cfset start = 1>
    <cfset end = 20>
    <cfset lastRow = #counter#>
    <cfloop from="#start#" to="#end#" index="loop">
    <cfset ThisEmail =
    listGetAt(cfhttp.filecontent,loop,"#chr(10)##chr(13)#")>
    <CFQUERY NAME = "CheckEmail" DATASOURCE="t">
    SELECT Email
    FROM Subscriber_Info_New
    WHERE Email = '#ThisEmail#'
    </CFQUERY>
    <CFIF CheckEmail.RecordCount EQ 0>
    <CFQUERY NAME="Insert" datasource="t">
    INSERT INTO Subscriber_Info_New
    (Email)
    VALUES (<cfqueryparam cfsqltype="CF_SQL_VARCHAR"
    value="#Trim(ThisEmail)#">)
    </CFQUERY>
    </CFIF>
    </cfloop>

    quote:
    Originally posted by:
    Newsgroup User
    I cannot lengthen the timeout so I need to figure out a way
    to process
    the data in chunks. Thanks.
    Are you sure you can not lengthen the timeout. The
    <cfapplication ...>
    tag allows one to define a specific timeout for a given page,
    as long as
    that is less then the maximum timeout defined in the
    administrator.
    If this is not sufficient for your needs you will need to
    break up your
    process over multiple requests. Just starting and stopping
    the loop in
    a singe request does nothing for reducing the timeout
    threshold of the
    page. You can do this with scheduled tasks, web services,
    and|or the
    <cflocation ...> tag. You will need to pass through
    relevant data about
    what iterations to process, and use some kind of extra
    request storage
    for the results, such as server|application|session scopes,
    databases or
    files.
    Hope that gives you some help.
    Ian
    Sounds like more than I know how to do. I cant change the
    timeout because its set that way on purpose. I think Ill leave this
    alone for now. Thanks.

  • Any way to stop auto shared volumes from opening in finder when booting?

    Leopard 10.5.8, but has been happening since at least 10.4.x...I have auto mounts setup in my user preferences, the auto mount fine, but the automatically open up too...makes it very annoying having to close all windows every time I boot the system...we have multiple Mac Pros running both Leopard and Snow Leopard...is there any way to stop the opening of the shares when I boot? maybe an applescript or something? thanks.

    there are some fancy solutions to this using autofs or /etc/fstab but a less involved method might be by using applescript. open Applescript editor (it's in /Applications/Utilities) and paste the following in it
    mount volume "afp://nas.ip.address/path-to-share"
    add a line like that for each share you are mounting.
    save the script as an application and add it to your login items. on the first try it will ask you to enter user name and password if your shares have any. enter those and check the box to save it in the keychain. it won't ask again. this will mount those shares without opening separate finder windows.

  • Is there a way to determine if an application is 32-bit or 64-bit?

    Is there a way to determine if an application is 32-bit or 64-bit? To be more specific, I want to be able to determine if a 32-bit application is being emulated under WOW64. I'm trying to use the Call Library Function and selecting IsWOW64Process from the Kernel32.dll, but I can't seem to get it to work. I think I may be setting it up wrong. I'm using a constructor node and invoke node for Process and after calling GetProcesses in the invoke node I'm sending that into a For Loop to inspect each process seperately. Inside the For Loop is where I'm trying to use the Call Library Function. From what I've read IsWOW64Process has a Handle as an input and a pointer to a boolean as an output. I may be incorrect in this as I've seen multiple varieties of this call on the internet. I've tried setting this up but I can't seem to get it to work. I'm looking for help on how to correctly use the Call Library Function or if anyone knows a better way to do this I'm open to suggestions. Thank you for any help. 
    Solved!
    Go to Solution.

    Hi klynn,
    I've got a link you might want to check out to make sure that your call function is correct.
    http://msdn.microsoft.com/en-us/library/ms684139%28v=vs.85%29.aspx
    I would also recommend that you check out DLL.VI example in example finder.
    Example Finder > Communicating with External Applications > Using External Code> Integrating DLLs > Call DLL.vi
    Hope this helps,
    Josh L.
    Applications Engineer
    National Instruments

  • Is there any way to stop a process execution (all instances)

    Hello,
    I´d like to know if there is any way to stop a specific process for execution at the engine without need to undeploy it, since we don´t want to loose process instances when we need to start this process for execution latter on.
    We have a PRD environment with a lot of processes from different departments (developed by different teams and external suppliers) and a feature for stop a specific process and isolate the environment could be very good to do root cause analysis when issues occurs at the environment.
    Sometimes stop a specific process (or some of them) could help in issues investigation that causes the engine to malfunction (lot of audit enabled, some loop bad controlled, lot of concurrent access) but I could not see this option at the webconsole.
    In the version 5.7 one EAR was created separatedly for each process deployed and this could be done stopping the EAR created for that process. Anyone know how to do this at version 6?
    Thanks

    Well the bad news is you are right, there really isn't any way to do this in versions after 5.7
    Starting at 6.0 all projects are deployed under the 'engine ear'. So if you stop the engine, you stop all projects deployed.
    I'm a little concerned that you are first seeing these issues in a 'PRD' environment, is this something that you could set up in a DEV, or UAT, or SIT, or any other environment (That is built similarly) to recreate the issues? - Then undeploy any of the other projects... and isolate the problem...
    -Kevin

  • How to stop while loop when a specified function is terminated?

    I want to make a program which has 2 thread, one of which is to control some devices, and the other is to measure outputs of the devices.
    To do that, I should make a 2 independent loops, but there comes a problem here.
    I want to terminate 2 loops at the same time, but it's difficult for me to do that, because when I try to notify upper sequence's termination to lower loop by some value change, they have some dependency.
    That's why I need your help. I want to know how to stop lower loop when the upper sequence's termination keeping their independency.
    Please let me know. Thank you.
    Attachments:
    help.JPG ‏200 KB

    Is the upper loop commanding the lower loop at all?  I would think you would have some type of communication between the loops.  Just use that communication to send a stop command.  Or the next best way is to just simply use a notifier.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • Only way to stop bonjour erros was to stop bonjour via services windows 7

    never had an iTunes issue with any version until i jumped on 9.1.079
    what stupid choice as while windows sees my iphones 3gs and i always manage iphonemanualy there are some parts i do sync.
    first sign of trouble was right after installation i usually rite click my iphone and choose backup when its open in iTunes which took forever!
    anytime i charge iphone or it's connected to computer and itunmes is open i show 4 erros in event viewer which i posted about in another post. only way to stop it was go into control panel>administrative tools>services> double click Bonjour and change for automatic to disable! hit apply/ok and done.
    still wether it's on or off diagnostics in iTunes shows all is well but it can't see iphone??? what it shows it in itunes it allows me to back it up add /remove songs change contacts/sync apps....but it reports it doesn't see iPhone.
    this i believe is all because of the bonjour not working properly.
    this is a clean install of windows 7 professional 64 bit.
    prior to this i ran vista ultimate 64 bit and didn't get any issues on same computer.
    i can't believe APPLE hasn't acknowledged a problem thats all over the internet as a google shows.

              Anamitra wrote:
              > Hi All
              > I was looking into how to stop an MDB from getting messages from a Queue. In case
              > of Weblogic 7.0 the only ways I could find was either to undeploy the bean or
              > to set the target off. Both the methods seemed a bit crude to me - especially
              > the first one. For the "off target" approach - I am not sure what Weblogic does
              > internally - whether it undeploys the bean or not.
              I'm not sure either, post to the ejb newsgroup for answers.
              In 7.0 and 8.1, you can also unset the target for the JMS server.
              This shuts down the JMS server. Resetting the target on the JMS
              server reboots it.
              >
              > If I look into Websphere 5 JMS implementation of MDB - they have a concept of
              > listeners where one can start or stop the lstener for an MDB - that seemed to
              > be a better design choice to me - this just turns off the tap from the App server
              > side rather than forcing the application to be undeployed.
              >
              > Is there any better way to stop an MDB from receiving messages in WLS 7.0 or 8.1?
              No. There are plans for addressing this issue in the next release.
              >
              > thanks
              > Anamitra
              Your welcome,
              Tom, BEA
              

  • Is there any way to stop running apps from showing in dock

    Is there any way to stop running applications from showing in the dock

    MacUpdate.com for OnyX or TinkerTool, one of those has the ability to lock the Dock so no changes occur, basically giving you what you want.

  • Is there any ways to stop Quicktime player from occupying audio hardware?

    Hi, my PC system is Window XP Pro SP2, HP xw8400 Workstation w/ 2G Ram. And the PC has a Digidesign Pro Tools HD 1 audio system installed.
    My problem is that after Quicktime player lauches, it will occupy the Pro Tools HD's hardware. And if I want to start Pro Tools software, "digidesign hardware is in use by another application." warning will occur and Pro Tools software will then quit. BTW, Digidesign's audio driver is not multi-clients compatible.
    I have set Quicktime player's audio playback device to PC motherboard's audio device, and system's audio device is also motherboard's audio device, I even have checked the "use default device only" option. I can't understand why Quicktime player still occupies Digidesign's hardware, even it plays back audio through motherboard's audio device.
    Though I can quite Quicktime player before lauching Pro Tools software, I still feel it's annoying and inconvenient, and want to know some ways to solve this problem.
    Anyone can help? Thanks in advance. I have asked for help in Digidesign's offcial forum, no response.
    BTW, the Quicktime player version on my system is 7.6.5, and each time Quicktime player launches, the sample rate led on the Digidesign's audio interface will flash, indicating that QT player is accessing Digidesign's hardware.
    Message was edited by: compusic
    Message was edited by: compusic

    Victor.jacob wrote:
    I have a Blue Ant Q2 Bluetooth headset. When it's paired, is there any way to stop all audio from streaming to it? I want to hear the iPad "ring" so I don't have to have the earpiece in my ear all day, or be able to play audio through the speakers instead of the earpiece. I feel like I'm missing something simple.
    You are missing something simple but lets get it to stop as you want. Go to Settings/General/Bluetooth turn it off.

Maybe you are looking for

  • How to print smartform from a report

    Im displaying a report, which contains several documents, whereby which ewch document is connected to a smartform. The page displaying the report contains a button 'Print' When clicking on the Print button, all the documents in the report should be p

  • Error while loading shared libraries: libstdc++.so.5: cannot open shared ob

    Hi people, I want to launch ./sapinst on suse O.S, but I´ve found with this message error: error while loading shared libraries: libstdc++.so.5: cannot open shared object file I´ve trying to search in notes, but i dont know how to resolv this. In the

  • Component tree destroyed when it should not be

    I have a custom component which derives from UICommand, clicking on which pops up a new window ... i have a listener associated with this component ... within this listener I call the setAction(outcome) method on the associated UICommand component wi

  • AirPort Express / Windows XP / Wi-Fi system tray icon

    Hello. On Sunday I've purchased AirPort Express and have been installed. My MacBook and iPod Touch work correct with router. Its connect to AirPort and get access to the Internet. But my not primary computer (PC laptop) work strangely. I switch on wi

  • Oracle to BEA

    Is it possible to post a message from Oracle to a BEA JMS Queue? Thanks