How can I make Process.waitFor() just wait for a limited period?

For example,
Process prc=Runtime.getRuntime().exec(cmd);
prc.waitFor(some seconds);
if(prc.exitValue() != 0){
// the subprocess hadn't terminated normally in some seconds,
// so just forcilly kill it.
prc.destroy();
Is there any way to do this?

waitFor does not have a timeout parameter, but you can start a Timer or thread to interrupt your waiting thread when the timeout expires. Then, waitFor will end, throwing an InterruptedException that you can catch.

Similar Messages

  • How can I make a while loop wait for input boolean?

    Hi.
    I'm trying to control a robotic arm with labview for my undergrad dissertation, and I have a decent polar coordinate control panel made, but there is one problem; it checks for changes in the coordinates every five seconds, while I want it to only check on the touch of a button (ie, go!, I've changed your coordinates!). The changes are calculated with a while loop comparing the last value of theta, x and z in a while loop with the current one. I can't find a way of putting that into a case structure. If there is a way of making the while loop progress at the push of a button, I think it would work. The VI's attached below.
    Thanks in advance for any help.
    Cathal Scanlon
    ps, sorry about the mess, I'm going to reorganise the while loop into 2 if I can get the control button working.
    Message Edited by CatScan on 02-08-2007 02:45 PM
    Attachments:
    Polar coord assignment1.vi ‏142 KB

    Have you tried using an event structure? To use one, right click on the structure to add an event. Set the event as whatever button you wish to monitor and set the event to "Value Change". If you put this inside a while loop any time the button is pressed, the event structure will run the contents inside the loop. There are a number of options to have the event structure activate.
    *** Warning! I'm probably the last guy you want answering your labVIEW questions, but I figured I might be able to help.

  • How can I download a transfer without waiting for it be all transferred?

    How can I download a transfer without waiting for it be all transferred? Thanks.

    Thanks, that now makes sense. Once an item enters the download queue, the user cannot remove it. Either let it complete the download (easiest) or contact the iTunes Store customer support department through the Contact page (select the category and subcategory closest to the issue you're reporting and you'll find either an "Express Lane" button - just follow the instructions to get to the contact form - or an "Email Us" button) and ask them if they'll remove the item(s) from your queue for you.
    Regards.

  • How can I make Adobe Reader 9 open for incoming PDFs instead of Acrobat 5.0?

    How can I make Adobe Reader 9 open for incoming PDFs instead of Acrobat 5.0?

    Hi,
    Assuming that you have Reader 9.3.4 already installed on your machine, you can try the following to make Reader 9.3.4 as the default PDF opening application:
    1. Right click on any PDF on your system and click on the "Open With" Option in the context menu that appears. In case you get another submenu, click on Chose Program in that menu. (In case you do not see any "Open With" option, then hold down the Shift key and right click on the file)
    2. Click on Browse button in the dialog that appears, and select Reader 9. Make sure that you select the checkbox for "Always use the selected program to open this kind of file"
    3. Click on OK.
    This will make Adobe Reader 9 as the default viewer for all PDFs on your system.

  • Can i make a method to wait for 2 mins before executing in java??

    can i make a method to wait for 2 mins before executing??
    i mean when i execute a method ....it has to wait for 2 mins before finally executing...
    can i do this in java????
    Thanks,

    Sure, put this at the beginning of the method.
    try
        Thread.sleep(120000);
    catch (Exception ex)

  • How can I make "No Proxy" the default for accessing the internet?

    How can I make "No Proxy" the default for accessing the internet?

    *Tools > Options > Advanced > Network : Connection > Settings
    If you do not need to use a proxy to connect to internet then try to select "No Proxy" if "Use the system proxy settings" or one of the others do not work properly.
    See "Firefox connection settings":
    *https://support.mozilla.org/kb/Firefox+cannot+load+websites+but+other+programs+can

  • How can i make Apple review a refund for a delaminated bottom case of my macbook november 2009 model? They more than implied that it is a design flaw anyway

    How can i make Apple review a refund for a delaminated bottom case of my macbook november 2009 model? They more than implied that it is a design flaw anyway. They make it so hard to send a possible review of such.

    http://www.apple.com/support/macbook-bottomcase/

  • How can I make my apple ID valid for purchases other then the Canadian iTunes Store?

    How can I make my apple ID valid for purchases other then the Canadian iTunes Store? I wanted to download the "Wath abc family" app and it said it had to switch me to the american store because the app isnt available in Canada yet. Once it switched me I put in my apple ID and password and thats when it said that my apple ID is only valid in the canadian store and it switched me back. 
    1)
    2)
    3)

    To make purchases in the Mac App Store/iTunes Store for any particular country, you must be a legal resident of that country and supply a credit card issued by a bank in that country with a verifiable billing address in that country. Do you also make those qualifications in the US?
    But as a side note, as one who has that app, you can only watch both ABC and ABC Family shows if you have an account with a US cable or satelite TV company with which to sign into the app. Otherwise you don't qualify to watch shows with it.

  • How can I make a custom domain email for my client?

    I have an Adobe Muse subscription, with hosting through Adobe, and the Domain name is also with Adobe. How can I make an email for a particular domain for my client so that it will use a "company email" (even if it just redirects to say a gmail or yahoo that is fine) to read "[email protected]?

    Hello,
    As I can see you have a WebBasic Creative Cloud site, I would suggest you to use GoogleApps for your e-mail services.
    Please have a look at the article which would help you achieve this : http://helpx.adobe.com/business-catalyst/partner/setting-google-apps-email-business.html
    Hope this helps.
    Regards,
    Sachin

  • How can i make hyperlink to local file for dowloading

    How can I make hyperlink to a local file for downloading it, it seams that only www links work in web Ui.
    Thanks

    If we assume that you have a LabVIEW application running on your cRIO that is exposing some data through web services, there are a couple of possibilities.
    You can create a web service call that returns the log data. In order for the browser to treat this as a file, you must set the correct content type in the http header. To do this you can't use the default form of data output. Instead you must create an "httpRequestID" input to your web service VI. With this you can call "Write Response.vi" to give the log data and "Set HTTP Header.vi" to specify the type (text/text probably works for a log). You can look at "examples\comm\webservices\address book\FindContacts.vi" to see an example of calling these 2 VIs. Once you create that web service entry point, you can set that as the URL of the hyperlink control and it should work.
    Another option is to have the cRIO application write to a log file that is under the root of the web server running on the machine. (This is the same place the xap for your Web UI Builder application is put.) This file could then be served up through the web server just like any other file.
    With either of these solutions there may be concerns about the browser caching results rather than requesting new content each time. There are additional values that can be set in the http headers with the first solution that can help with this, but I think there is still some variation between browsers.

  • How can i make a pl/sql function for BLOB datatype

    hi..anyone here who is very familiar about BLOB datatype. i have a COLUMN_ID, COLUMN_A in a certain TABLE_1. COLUMN_A is blob datatype that contains almost 250,000rows
    SQL>select column_A from table_1 where column_id=1234567
    column_A
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    how can i make a user-defined function to compute and convert this blob datatype into decimal length value. this hex value are points in the map.. the function must contain
    1.get the length of a blob then
    2.convert blob to variable hexadecimal characters by parsing it into 8
    3.to_number function or other function used to convert haxadecimal characters to decimal numbers
    4.phythagorean formula to compute length between two points. this is the formula i think LENGTH =
    SQRT(power((coordinate_x-prev_coordinate_x),2)+power((coordinate_y-prev_y),2));
    after this when i type this
    SQL>select user_function(column_A) from table_1 where column_id=1234567
    user_functions(column_A)
    --output length will be in decimal value already
    the function will goes like this
    step1 is to get the blob length
    00000001000000010000000606D4E833074B69EC06D4E91F074CO18406D50C58074C031E
    step2 is parsing of data by eights
    00000001 =>1
    00000001 =>1
    00000006 =>6 (number of coordinates)
    06D4E833 => X1
    074B69EC => Y1
    06D4E91F => X2
    074CO184 => Y2
    06D50C58 => X3
    074C031E => Y3
    step3 to_number function used to convert hex char to decimal
    step4 compute by phytagorean (NOTE ! when computing length the third parsed eight will tell how many coordinates are there..the number of coordinates is ranging from 2 up to E..above example shows 6 coordinates so it means
    LENGTH1 =
    SQRT(power((X2-X1),2)+power((Y2-Y1),2));
    LENGTH2=
    SQRT(power((X3-X2),2)+power((Y3-Y2),2));
    TOTAL LENGTH=LENGTH1 + LENGTH2
    thanks

    its my first time to use that.There's got to be a first tiem for anything. Be brave.
    btw if theres more easy suggestion pls feel free..Well of course the easiest solution would be if the calling program passed in the parameters as separate arguments instead of glomming them together in a string that has to be parsed. This sort of kluj really ought not to have survived into C21.
    Cheers, APC

  • How can i make Trend lines in numers for iPad

    Does numbers support trend lines? How can i make them?
    Thank you in advance

    Numbers on ipad does not give you the option of adding trend lines to your graphs at this time.
    Jason

  • How can I make a startup flash drive for a new iMac?

    My new imac came without an install disk.  How can I make a bootable startup drive from a flash drive for emergencies?

    http://support.apple.com/kb/DL1433
    Regards.

  • How can I make a while loop wait 10 seconds before iterations​?

    I am using labview to for an osmosis system that measures the amout of water lost from the reading on a scale.  
    I currently have the program displaying the data from 3 scales every second.
    I also need to calculate the flux through the membrane over time.
    I do this with a function that takes a change in the scale reading over time (with a shift register) followed by a series of mathematical conversions.
    The readings from the scale display OK every second, but I need to have at least 10 seconds between flux calculations.
    So my question is, how do I make a the shift register take one value from the scale, then wait 10 seconds before taking the second value?  That way I have the mass of water lost over a 10 msecond period.  
    Below is my current while loop for Flux using shift registers from data from 3 scales.  
    Any helkp would be great!
    Also, I'm new at LabVIEW...

    Bob_Schor wrote:
    Do you understand how Dataflow (a key idea behind LabVIEW) works?  If you put a Wait (ms) function (on the Timing Palette) with 10000 (10,000 milliseconds = 10 seconds) inside your While Loop, the principles of Data Flow will require all of the functions inside the While (specifically the Wait function) to finish their execution before the loop can run again.  As everything else in the loop takes approximately 0 seconds, this will make your loop run once every 10 seconds.
    Bob Schor
    I do not think that is a good idea. 
    The inner loop should be in sync with the outer loop, not run independent on it's own timer.
    If the inner loop is running independently you run the risk of using stale data.
    Actually  altenbach is right the inner loop does not need to be a for loop at all, but rather just a case like my suggestion (without the for loop) and the shift registers should be out on the main loop.
    My suggestion was a quick solution going by what little bit of the block diagram I could see, but if the entire code was posted I am sure we would see where more improvements could be made and possibly even a better solution.

  • How can i make my iMac stop asking for passwords?

    How on earth can I make my iMac quit asking me for passwords? I've tried a few attempts at resetting Keychain passwords. Nothing I do seems to change any behaviors. I'm also complete noob to Mac so go easy with the jargon. I've even had a session an apple support person and fixed it temporarily.
    my imac is current with OS X 10.9.2

    OS X: Keychain Access asks for keychain "login" after changing login password
    http://support.apple.com/kb/ht1631
    Resetting your keychain in Mac OS X
    http://support.apple.com/kb/ts1544
    If you can read through these, are these steps similar to what the Apple advisor had you do?

Maybe you are looking for