Waiting for Sub Process to complete

Hi,
Below mentioned is my requirement:
1. Main process begins
2. Copy a tar file from a source directory to target directory.
3. Call a sub-process to untar the file (using MKS tool kit utility from command prompt).
4. sub-process ends
5. Work on the folders (untared) by applying rules.
6. Main process ends.
When I call sub-process like
main() // main method
// calling sub-process
Process p = Runtime.getRuntime().exec(tar -xvf C:\\Source\\ -C C:\\Target);
p.waitFor();
// calling rules
rule("C:\\Target"); // private method to perform validation on the untared files located in Target folder.
//main method ends
The program gets stuck up here.
The file size to untar is small (1MB). But, after some time, when I kill the main process, I could see sub-process completing its task.
Can you any one suggest me to know the sub-process completion, so that I could call my rules()

I f you read the documentation for exec() and Process carefully you will find that when you an exec() a process, pipes are created back to the main process for the stdout and sterr of the sub-process. Those pipes have a finite size and when full the sub-process will block, hence waitFor() will wait forever.
You need to create threads to drain stdout/stderr of the sub-process, or else re-direct the subprocess output (start a shell to run the actual command) so that the pipes won't get full and block.

Similar Messages

  • How to wait for a Process to complete without using wait,notify methods

    I have created a new Process using run.exec() method using a cmdline String array in the format "java, class name, 4 command line arguments" to be passed to the main method of that class. But I have a maximum limit of the no. of processes to be created e.g. 5. So whenever I create a process, I use a static semaphore class to decrease the count, and increase it again when the process ends; so when the 6th process wants to start it will be suspended until another process is complete. My problem is how do I communicate to the calling class that the process has ended. I don't want to create any threads as that will defeat the purpose of creating separate processes. I have tried Process.waitFor() method but it doesn't work.

    you could add a iamfinished method to the class where you store the counter and thread calls it if it is finished.

  • WaitFor() doesn't wait for my process to complete?

    Hi all,
    I'm launching a browser from my java program to display a text file, and when this is done i want to delete that text file from the server, so i tell the process that launches the browser to wait, then i make a call to delete the file from the server
    my code goes something like this:
    Process browserProc = Runtime.getRuntime().exec(<command to launch browser>);
    browserProc.waitFor();
    //here i call an external process to delete the file
    this works sometimes, but others the file is deleted before the browser gets to display it. what am i doing wrong?! if this is due to subprocesses being spawned is there any solution? any help is greatly appreciated!
    thanks and regards,
    emh3

    This is from some legacy code..urlToPointTo is the url
    of my file - does this fall into that category?Apparently it does. And it should, too. I can see the designers thinking "Should this command wait until the GUI is closed? No. Of course not. Obviously the user of this command only wants to launch the GUI. Why on earth would they want to wait until it is closed?"
    When you are having so much trouble doing something so simple, that's a good indication that you're doing something that isn't a good idea. Can you explain why you need to delete the remote file after it's displayed? Maybe that was your idea of how to implement some other requirement.

  • SHUTDOWN: waiting for detached processes to terminate

    HI
    I have cold backups running every night and before the backup session starts, we have a cronjob 'srvctl stop -p prod' where our db servers are running on RAC.
    but starts from last saturday, our backup session for raw device failed. when look at the alert log, it gives as (example on 15th November 2006)
    Tue Nov 21 01:33:31 2006
    Thread 1 advanced to log sequence 2855
    Current log# 1 seq# 2855 mem# 0: /u01/oracle/oradata/prod/redo_1_01_01.log
    Current log# 1 seq# 2855 mem# 1: /u01/oracle/oradata/prod/redo_1_01_02.log
    Tue Nov 21 02:37:24 2006
    Reconfiguration started
    List of nodes: 0,
    Global Resource Directory frozen
    one node partition
    Communication channels reestablished
    Server queues filtered
    Master broadcasted resource hash value bitmaps
    Non-local Process blocks cleaned out
    Resources and enqueues cleaned out
    Resources remastered 13089
    147420 GCS shadows traversed, 0 cancelled, 18306 closed
    63793 GCS resources traversed, 0 cancelled
    98369 GCS resources on freelist, 162162 on array, 162162 allocated
    set master node info
    147420 GCS shadows traversed, 0 replayed, 18306 unopened
    Submitted all remote-enqueue requests
    Update rdomain variables
    0 write requests issued in 129114 GCS resources
    1 PIs marked suspect, 0 flush PI msgs
    Dwn-cvts replayed, VALBLKs dubious
    All grantable enqueues granted
    Tue Nov 21 02:37:27 2006
    Reconfiguration complete
    Tue Nov 21 02:37:28 2006
    Instance recovery: looking for dead threads
    Instance recovery: lock domain invalid but no dead threads
    Tue Nov 21 02:37:29 2006
    Shutting down instance: further logons disabled
    Shutting down instance (immediate)
    License high water mark = 90
    Tue Nov 21 02:37:29 2006
    ALTER DATABASE CLOSE NORMAL
    Tue Nov 21 02:37:29 2006
    SMON: disabling tx recovery
    SMON: disabling cache recovery
    Tue Nov 21 02:37:34 2006
    Thread 1 closed at log sequence 2855
    Tue Nov 21 02:37:38 2006
    Completed: ALTER DATABASE CLOSE NORMAL
    Tue Nov 21 02:37:38 2006
    ALTER DATABASE DISMOUNT
    Completed: ALTER DATABASE DISMOUNT
    ARCH: Archiving is disabled
    Shutting down archive processes
    archiving is disabled
    Archive process shutdown avoided: 0 active
    ARCH: Archiving is disabled
    Shutting down archive processes
    archiving is disabled
    Archive process shutdown avoided: 0 active
    Tue Nov 21 02:42:49 2006
    SHUTDOWN: waiting for detached processes to terminate.Tue Nov 21 07:16:38 2006
    Starting ORACLE instance (normal)
    Seems like it was hang when 'shutdown immediate' command is issued. can somebody help me? what should i do?
    Thanks
    Best regards,
    Nonie

    Hi nonie
    Oracle shutdown Problem
    If the following message is in the Oracle alert file:
    SHUTDOWN: waiting for detached processes to terminate
    you should change the SERVER and SRVR parameters from SHARED to DEDICATED in the file <ORACLE_HOME>\network\ADMIN\tnsnames.ora.
    http://serviceportal.fujitsu-siemens.com/i/en/support/technics/fgm/unix/nsr40a_en.htm
    hope this helps
    Taj.

  • Timed out waiting for Business process

    Hi,
    I created a web application using evision in JCAPS 512. It works properly. But some times i am getting an error message as
    "Timed out waiting for business process" when i try to access the web page usign url.
    But if i invoke page again then application works properly.
    I have increased server response timeout value also. But couldn't get
    the reason when it will occur.
    Please let me know what is the reason for this problem. If this error occurs please let me know is it possible to show some other page instead of displaying error to user.
    Regards
    Venkatesh.S

    Good day.
    I have a similar problem and I have managed to pinpoint when it fails but unfortunately I don't know how to fix it yet.
    In my scenario, I have 2 separate processes:
    the first process reads data from a Seebeyond SRE instance and stores it on a local Java CAPS queue.
    The second process is an EVision process that reads the data from this queue and displays it on a page.
    Whenever I am not connected to the network linking my Java CAPS instance to the Seebeyond SRE instance (first process cannot connect ) I get this problem on the EVision side every second time I request a page. This means I can view the first message on the queue and then I have to restart the Logical Host
    This doesn't make sense to me, since The EVision process is a completely separate process, deployed in it's own WAR file.

  • SHUTDOWN: waiting for active calls to complete.

    Hello,
    environment is HPUX 11.23, Oracle Version is 9.2.0.5
    We had an ORA-600 error yesterday. We reported that error to the support and were suggested to install patch 9.2.0.8.
    However i have one question. As you can see from the output in the alert-logfile it took a very long time to shutdown the instance using the immediate option:
    Sun Nov 9 17:33:58 2008
    Shutting down instance: further logons disabled
    Shutting down instance (immediate)
    License high water mark = 454
    Sun Nov 9 17:39:07 2008
    Active call for process 3991 user 'oracle' program 'oracle@xyz (TNS V1-V3)'
    SHUTDOWN: waiting for active calls to complete.
    Sun Nov 9 17:50:36 2008
    ALTER DATABASE CLOSE NORMAL
    Is there anything one can do in such a situation to speed up the shutdown of the instance ?

    Rajabaskar Thangaraj,
    Oracle database has a job facility and a streams/advanced queuing facility.
    These facilities are possible by setting up a few ancillary processes.
    Those parameters govern the number of processes.
    Setting them to 0 will disable the facility completely.
    As you alter the parameter in memory, as you as you have bounced the database, it will be back to the value in the spfile and the facilities will work again.
    Disabling them is especially useful when you the facilities are frequently used, ie you have a job running every 30 seconds.
    In the past, on several databases, this was the only way to allow a shutdown immediate.
    Hope this helps,
    Sybrand Bakker
    Senior Oracle DBA

  • Waiting for scheduling job to complete. Job ID...and it never completes

    I have created my first Publication. It's a pretty basic single source document, single Dynamic Recipients list publication.
    When I run it in Test mode (I haven't tried it in non-Test mode yet), the document(s) are never delivered.
    When I view the Log File, everything looks fine. The second and last entry in the log says
    "- The global delivery rule for this publication was met; publication processing will now begin."
    The Status Message I see in the Publication History is:
    "Waiting for scheduling job to complete. Job ID:3,879, name:Unviewed Invoices Report (Copy), kind:CrystalReport in Pending state (FBE 60509) [0 recipients processed.] "  and it never changes. I've tried this several times, creating new publications with the same source documents, and the same thing always happens.
    Any help would be appreciated.

    All of the servers were configured correctly.
    It turned out to be my source document, a report, had some field in it that BOE didn't like.
    I removed a bunch of fields and added them back, one by one, and couldn't make the error occur again.
    Go figure.

  • Does WPF waits for GPU present to complete?

    I'm testing how frequently WPF display can change when I have one window per monitor. My frame rate isn't amazing, and using xperf and GPUView it looks like WPF prepares both windows and then calls "Present packet" on both at the same time, and
    waits for both to complete before moving on to send the next frames to the video card. I think my frame rate could have been faster if WPF didn't wait for the present to complete on both displays. When I run two WPF processes, each with one window on
    one monitor, the present packets are independent, so parallel processing is more efficient and the frame rate is higher.
    Did anyone observe the same behavior? Is there a flag I can set to make the WPF windows of one process more independent? 

    Hello Shir Oren,
    I'm confused about those monitors, do you mean you have a computer with a few monitors?
    Then "When I run two WPF processes" can you briefly introduce it here? Different applications on different monitor? Do you actually mean thread but not process here?
    Actually WPF can take advantage of both Hardware and Software Rendering Pipeline, for details please refer to MSDN article:
    https://msdn.microsoft.com/en-us/library/bb613578(v=vs.110).aspx
    I'm not sure whether there is a flag you metioned but I haven't found it at this time. So I recommend you focus on the exist WPF render tiers from here
    https://msdn.microsoft.com/en-us/library/ms742196(v=vs.110).aspx to consider raise your performance.
    Best regards,
    Barry
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • Getting java to wait for a process to end

    I have an application running Javac i need it to wait for this process to end before it does anything else.
    I have tried using theProc.waitFor() (the Process i have created), but this hangs my application. I know there is nothing wrong with the class paths and java itself. I have checked the process list and Javac is still in it. WHY?
    Can someone suggest anything.

    http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html

  • I tried to import 2 photos from an email. The photos are now on iPhoto, however, when I try to close iPhoto or turn off my computer, I get a notice that says, "Photos are being imported to the photo library. Please wait for the import to complete."

    I tried to import 2 photos from an email to iphoto. The photos now appear in iphoto as the latest imports, However, when I try to close iphoto or log off of my computer, I get a message box that says, " Photos are being imported to the photo library. Please wait for the import to complete."
    I can't get out of iphoto or log off of my computer, or turn the computer off. How do I stop the import or log out of iphoto???

    Try Force-quit from the Apple-menu to close iPhoto.

  • Trying to download a program and get "Waiting for other installations to complete"

    Trying to download a program and get "Waiting for other installations to complete"
    there are no other instalations going on that I know of Please help

    That is for your and your Mac's protection; you need your administrator password to download/install things.

  • Javascript: Wait for a redirect to complete - creating multiple PDF's

    Hi!
    Here is the code that I am using to try to generate multiple reports from javascript. how do I wait for the redirect to complete (ie. generate the PDF) before redirecting to generate the next PDF?
    In the code the "F106_" are application level items.
    I get have been able to get the very first or the very last PDF but none of the other PDF's.
    <script type="text/javascript">
    function f_DoReport() {
      for (i = 2; i <= 3; i++)
         for (j = 1; j <= 4; j++)
             var rgn = '0' + i;
             var dst = '0' + j;
             var vurl = 'f?p=&APP_ID.:30:&SESSION.:FLOW_XMLP_OUTPUT_R27022113101536736_en-us:&DEBUG.::';
             vurl += 'F106_RPT_REGION,F106_RPT_DISTRICT:' + rgn + ',' + dst;
             redirect(vurl);
             alert('rgn: ' + rgn + ' dst: ' + dst);
    </script>Please let me know if I am going down the wrong path here. :D
    As always thanks for your time and help!
    Dave Venus

    A few questions…
    Do you want a script that works with just the active document and you are going to run 300+ times? If so then this may do…
    #target illustrator
    function artboardsToPDFs() {
         if (app.documents.length = 0) {
              reurn;
         } else {
              var docRef = app.activeDocument;
              var docName = docRef.name;
              var baseName = docName.replace(/.ai$/,'');
              var dF = docRef.path.fsName;
              var aB = docRef.artboards;
              var pdfOpts = new PDFSaveOptions();
              pdfOpts.pDFPreset = '[Press Quality]';
              for (var i = 0; i < aB.length; i++) {
                   var numb = (i+1).toString();
                   pdfOpts.artboardRange = numb;
                   var pad = aB.length.toString().length;
                   numb = zeroPad(i+1, pad);
                   var pdfFile = File(dF + '/' + baseName + '_' + numb + '.pdf');
                   if (!pdfFile.exists) {
                        docRef.saveAs(pdfFile, pdfOpts);
                   } else {
                        var rPDF = confirm('File: "' + pdfFile.name + '" already exists…\rDo you wish to replace?',false);
                        if (rPDF) {
                             docRef.saveAs(pdfFile, pdfOpts);
                        } else {
                             continue;
    artboardsToPDFs();
    function zeroPad(n, p) {
      var t = n.toString();
         while (t.length < p) {t = '0' + t};
      return t;
    Do you want to pick a folder of all the illustrator files? If this is the case I would need more info and it would take longer…

  • Microsoft Excel is waiting for another application to complete an Ole actio

    When I access Data Manager, I get the error message: "Microsoft Excel is waiting for another application to complete an Ole action."  When I click OK, I get another error: "Cannot download the dimension list from server.  Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached."  It never used to happen until recently.  I don't know what to tell the IT guys to do.  Thanks.

    This is a known error in V5. I have had this error at almost every V5 customer.
    The following solution (got it from support) solves it permanently.
    Changes have to be made to the outlooksoft.config file and the connectionstrings in tblappsetinfo. Be sure to restart the server(s) after applying these changes.
    1. In outlooksoft.config file of x:\OutlookSoft\Websrvr\bin folder on the web server change the following line:
    <add key="Database_AppServerDBConn" value="Server=<servername>;Database=AppServer;Trusted_Connection=True;"/>
    to
    <add key="Database_AppServerDBConn" value="Server=<servername>;Database=AppServer;Trusted_Connection=True;pooling=false"/>
    Please note that where I have <servername> you should put the name of your server ****
    Also, add the pooling=false; to every connection string in tblappsetinfo.
    I am sure this helps,
    Regards,
    Alwin Berkhout

  • Installer keeps waiting for other installations to complete my downloads.  is this normal?

    I downloaded a microsoft remote desktop application and tried to download my office mac and the installer keeps saying waiting for other installations to complete.  So i thought i needed a restart and the installer won't shut down either.  is this normal?

    Immediate problem solved. After force quitting the Software Update app., iPhoto 9.2 appears to have been successfully installed and functional.  Unable to say if future S/W updates will encounter any problems. Thanks for all consideration. Item closed.
    Aubrey

  • How to get OIM workflow waiting for a task successfully completed?

    The requirement is to get OIM provisiong workflow pending and wait for a external status ready. When the external status not ready, I return "REJECTED" which mapped to "P" in "Task->Reponse" tab. Meanwhile, in the "Task->General" tab, I set the "Retry Count" to 5 and "Retry Period in Minutes" to 1.
    I have hoped that once the task return "REJECTED", the workflow enter status "Pending". One minute later, the task re-instanced by OIM to have another check for whether the external status ready. If ready, return "COMPLETED". If not yet, return "REJECTED" and workflow re-enter pending. And on and on, until to max to 5 times attempt. But in fact, OIM workflow never attempt to re-enter the task again after the 1st time "REJECTED" returned.
    How to do with this?

    Use the code snippet below to get the task status. Based on this you can filter rejected tasks.
    userintf = (tcUserOperationsIntf) ioUtilityFactory.getUtility("Thor.API.Operations.tcUserOperationsIntf");
    provintf = (tcProvisioningOperationsIntf)ioUtilityFactory.getUtility("Thor.API.Operations.tcProvisioningOperationsIntf");
    long userKey=100;
    tcResultSet userresultSet = userintf.getObjects(userKey);
    for(int i=0;i<userresultSet.getRowCount();i++)
         userresultSet.goToRow(i);
         long processKey = userresultSet.getLongValue("Process Instance.Key");
         tcResultSet provresultSet = provintf.getProcessDetail(processKey);
         for(int j=0; i<provresultSet.getRowCount();j++)
              provresultSet.goToRow(j);
              String taskName = provresultSet.getStringValue("Process Definition.Tasks.Task Name");
              String taskStatus = provresultSet.getStringValue("Process Instance.Task Details.Status");
    Let me know if you have any queries...

Maybe you are looking for

  • Apple TV Movie Purchases Playback Support

    I have a 3rd generation Apple TV. I have purchased and retned dozens of movies; and never experienced any issues when viewing them up until recently (all of them on 1080p). I have Verion Fios, and recent speed test clock my speed at over 50mbps. The

  • HELP! Modify SAVE dialog file format options?

    Can someone please tell me how to modify the options in the save dialog? Every time I save a file and have to choose the file type, I have to scroll through obscure and obsolete file types. Sure, I might need someday to save Scitex CT, or Photoshop D

  • TS1359 Why are no new movies showing up but any old movies I purchase show?

    Movies like the avenger and rock of ages will not show up, but any other older movies I purchase in HD show up? I can play them on my ipad and iphone and the newer apple tv but not my old gen 1 apple tv

  • Copying PO STO currency to Accounting Document

    Hi, Do you have any idea how I can copy the PO STO Currency to Accounting Document in VF01? I managed to copy the PO STO currency to the billing document by using USEREXIT_PRICING_PREPARE_TKOMK. Now I need to make sure that the accounting document wi

  • Database with Java

    if i wannaa develop a system with accessing database or update , insert ,delete.. which database system shall i use for Java?? MySQL??SQL2000?Access??MSDE? are those working fine with JAVA?