Exec calls do not appear to be returning to the program

After our NT server was rebooted, all of the sudden the Java program I maintain failed to work properly. The program creates a thread and within that thread multiple exec calls are made. It appears that the program is hanging in the portion of the code that is handling the InputStream and ErrorStream of the processes created by exec():
Process process = null;
String processArgs[] = { .... };
try
java.util.List processes = new java.util.Vector();
java.io.InputStream streams =
new java.io.InputStream[jobList.length*2];
int streamCount = 0;
for (int streamLoop = 0; streamLoop < jobList.length; streamLoop++)
process = Runtime.getRuntime().exec(processArgs);
processes.add(process);
streams[streamCount++] = process.getInputStream();
streams[streamCount++] = process.getErrorStream();
int size = 0;
int remainingCount = streamCount;
byte b[] = new byte[4098];
do
for (int loop = 0; loop < streamCount; loop++)
size = streams[loop].read(b, 0, b.length);
if (size == -1)
remainingCount--;
streams[loop] = null;
} while (remainingCount > 0);
java.util.Iterator processList = processes.iterator();
while (processList != null && processList.hasNext())
process = (Process) processList.next();
process.waitfor();
catch (Exception e)
This chunk of code accepts an array of files that need to be processed simultaneously. The code should exit once all of the child processes have exited.
After the reboot of NT, this code just hangs. I look at the log of the child processes (the child process is a vendor program) and it appears to successfully exit. Running the child processes from the command line or from a DOS batch script doesn't cause anything to hang.
To debug this, I placed the code chunk:
else
System.out.println(new String(b, 0, size));
below the condition for: if (size == -1). Magically, the program no longer hung. Subsequent debugging points to the program hanging in the portion of the code that reads the Input and Error streams from the process.
Since I'm a C/Perl programmer, I'm not quite understanding why I even need to deal with the child processes output when I don't even care what's in it. And I'm completely baffled as to why this program would hang at all... especially when this problem has only cropped up since the server was rebooted. I believe it has something to do with the child processes putting out different length output streams and perhaps tweaking with the read buffer size would help, but that really doesn't explain the underlying problem.
Does anyone have a clue what may be going on given my explaination of the problem?
TIA,
Curt

do {
    for (int loop = 0; loop < streamCount; loop++) {
        size = streams[loop].read(b, 0, b.length);
        if (size == -1) {
            remainingCount--;
            streams[loop] = null;
} while (remainingCount > 0);Like they say in the API documentation of read(byte[], int, int), "this method blocks until input data is available, end of file is detected, or an exception is thrown." This is useful in some situations but not here. You can check how many bytes are available with the method "available()". So I suggest modifying        size = streams[loop].read(b, 0, b.length);to        int available = Math.min(streams[loop].available(), b.length);
        size = streams[loop].read(b, 0, available);Also, you need to check if streams[loop] is null before trying to read since when you start reaching the ends of the streams some references in that array will be null and you'll be getting NullPointerExceptions.. so the fragment should be        if (streams[loop] != null) {
            int available = Math.min(streams[loop].available(), b.length);
            size = streams[loop].read(b, 0, available);
        }I think you should also remember to close the streams, so change the rest to        if (size == -1) {
            remainingCount--;
            streams[loop].close();
            streams[loop] = null;
        }> Since I'm a C/Perl programmer, I'm not quite understanding
why I even need to deal with the child processes output when
I don't even care what's in it.My C experience is pretty much null and void but don't you have to do that in C too?
I don't know, maybe that's yet another quirk of the language...

Similar Messages

  • I've found two bugs in iOS 7. 1) declined calls does not appear as missed calls on the lock screen/notification centre. 2) when bluetooth is enabled from control center, it does not connect to an already paired bluetooth device

    I've found two bugs in iOS 7:
    1) declined calls does not appear as missed calls on the lock screen/notification centre - iOS 7.0.2.
    2) when bluetooth is enabled from control center, it does not connect to an already paired bluetooth device automatically - iOS 7.0.

    We are all users here, just like you, but you can tell Apple about it by using this link:
    Apple - iPhone - Feedback

  • HT2486 want to know how to add pictures to address book that DO NOT appear as fullscreen images on the iPhone but remain as icons with the iPhone background visible

    want to know how to add pictures to address book that DO NOT appear as fullscreen images on the iPhone but remain as icons with the iPhone background visible (see attached image). for some reason, all new contacts added through Mountain Lion appear as fullscreen caller ID images.

    This would be better addressed in the iPhone forum, I would post there as well.

  • For some artists in my Music app on my I-phone, the songs do not appear when I search by the artist.  However, if I search the album name, all the songs show.  How do I get the songs to show under songs?

    For some artists in my Music app on my I-phone, the songs do not appear when I search by the artist.  However, if I search the album name, all the songs show.  How do I get the songs to show under songs?

    Hi Spam_Valley,
    I understand that you are having issues with your music displaying correctly. This may be an issues with the metadata stored within that song, and iTunes interpretation of that info.
    We may need to repair this. See the following resources for information:
    iTunes 10 for Windows: If song titles don’t appear correctly
    http://support.apple.com/kb/PH1468
    Fixing Incorrect Song or Album Listings in iTunes
    http://support.apple.com/kb/TA24677
    Thanks,
    Matt M.

  • I am unable to work on docs in adobe as the toolbar does not appear when I tap on the doc.

    how do I get my adobe to work? I open the doc in adobe but cant work on the doc. the toolbar does not appear when I tap in the middle. All contact us help leads to nowhere. the e mails from support cant be replied to. is there another app that one couls use to download doc and actually be able to work on them?

    What is your operating system?
    What is your Reader version?
    Are these local or online documents?  If online, in what browser?

  • How to fix The SIM card inserted in this iPhone does not appear to be supported. The SIM card that you currently have installed in this iPhone is from a carrier that is not supported under the activation policy that is currently assigned by the activation

    The SIM card inserted in this iPhone does not appear to be supported.
    The SIM card that you currently have installed in this iPhone is from a carrier that is not supported under the activation policy that is currently assigned by the activation server. This is not a hardware issue with the iPhone. Please insert another SIM card from a supported carrier or request that this iPhone be unlocked by your carrier. Please contact Apple for more information.

    Or if you've recently got the phone unlocked then you'll need to connect it to  itunes and then do a fresh restore to unlock it ,although for most users simply connecting to itunes for few seconds did the trick.

  • Does not appear lock option to cover the ipad2 with operational 5.01

    Does not appear lock option to cover the ipad2 with operational 5.01

    Did this with Adobe support in LIVE CHAT, what a waist of time.  Although this will correct the issue, it is like a work around and not solving why EDIT IN PHOTOSHOP... is not a clickable option (greyed out) in LR.
    After the configure as suggested above, does this preclude and editing in Lighroom?
    What I want to do is:
    Edit the photo in LR except for:
    the useage the great Spot Healing Brush Tool that PSE offers, edit that part of it in PSE then SAVE the results back to LR.  Any problems or suggestions for this?
    Thanks so much

  • HT201413 I have ipod 4 i want to sync the device to my pc through Itunes by the sync selection to my iTunes at PC were disable cause even the device are not appearing on iTunes PC but the iPod was connected to my PC how I can be able to fix this.

    I have ipod 4 i want to sync the device to my pc through Itunes by the sync selection to my iTunes at PC were disable cause even the device are not appearing on iTunes PC but the iPod was connected to my PC how I can be able to fix this.

    Hi there,
    If you are experiencing an issues where iTunes is not recognizing your iPod, then I would recommend taking a look at the article below.
    iPod: Appears in Windows but not in iTunes
    http://support.apple.com/kb/TS1363
    -Griff W.

  • TS2529 The SIM card inserted in this iPhone does not appear to be supported. The SIM card that you currently have installed in this iPhone is from a carrier that is not supported under the activation policy that is currently assigned by the activation ser

    The SIM card inserted in this iPhone does not appear to be supported.
    The SIM card that you currently have installed in this iPhone is from a carrier that is not supported under the activation policy that is currently assigned by the activation server. This is not a hardware issue with the iPhone. Please insert another SIM card from a supported carrier or request that this iPhone be unlocked by your carrier. Please contact Apple for more information
    what can in do?

    Well unfortunatly that advice does not always work. I bought a unlocked iphone4  from apple several years ago and went to att on a no contract basis. Six months later the phone crashed while updating the operating system. Apple replaced the phone with a new one. All is fine till I got a iphone5 and gave te phone to my cousin. The phone is now locked to att but att says the IMEI number is not a valid ATT IMEI and therfore cant unlock it. Apple says there is nothing They can or are willing to do so now I am stuck for a 600.00 phone that can't be used.
    If anyoun knows a way naround this situation mI would appreciate a heads up.

  • When I launch the app store, I get "minecraft." It will not allow me to return to the "featured" menu. I've tried rebooting / killing the app, but nothing has worked. Any insight?

    When I launch the app store, I get "minecraft." It will not allow me to return to the "featured" menu. I've tried rebooting / killing the app, but nothing has worked. Any insight?

    I have also tried the fixes offered in this forum such as using the "Other" mail in setting up the gmail accounts, and not using the dedicated gmail setting.  I also went to google and signed in and enable the additional devices.  I had the same problems with the original account I set up for gmail, but it corrected when i went to using the "Other" instead of the Gmail button.  I was able to set up the new gmail accounts on my iphone without problem and on my husband's ipad1 for his gmail account.  Just the ipad 2 is giving me problems.   Again, thanks for any suggestions.

  • Computer deletes installed programs at will, will not delete others, they return at the next log-in

    Computer deletes installed programs at will, will not delete others, they return at the next log-in. Some programs or hardware continue to operate even though you can't locate the programs or files on the computer. Will not disable some features when asked to.

    hello Ebenholmes, is this affecting your whole pc (in this case the problem is probably beyond the capabilities of the forum - you might have to install & setup your operating system from scratch again) - or is it only a problem within firefox? in the latter case please refer to [[How to fix preferences that won't save]], especially the part about the user.js file within your profile folder....

  • After the last update on iTunes I have not been able to get into the program. I have uninstalled all components and reinstalled and now it is telling me I am missing .dll files. I am so frustrated. I probably lost my entire library except what I purchased

    After the lastest update on iTunes I have not been able to get into the program. I have uninstalled all components and reinstalled and now it is telling me I am missing .dll files. I am so frustrated. I probably lost my entire library except what I purchased

    Your library should be safe.
    See Troubleshooting issues with iTunes for Windows updates.
    tt2

  • My program does not work properly. I run the program but it is not capable of adding any of my ebooks and when I connect my ereader, it recognises the device but  it does not add any ebook either.  I uninstalled the program and reinstalled again but nothi

    my program does not work properly. I run the program but it is not capable of adding any of my ebooks and when I connect my ereader, it recognises the device but  it does not add any ebook either.
    I uninstalled the program and reinstalled again but nothing gone better-
    What should I do?
    Best regards

    Do you have Logitech gaming software installed on the PC? If so, perhaps try the suggestion from the following post:
    Re: Everytime I close Itunes it loads back up

  • I'm not getting proper output as per the Program

    Hi Experts,
             As i'm executing my ALV report regarding Customer Invoice on Production client I'm not getting proper output as per the program but when i execute the same report on Development client i'm getting proper output.
          Can anybody tell me how can i resolve this problem on production client? 
          Actually i've updated my report on my old report but still i'm getting old output of my report on production client, Program is showing updated code but at execution i'm getting old output.

    FORM Z_CREATE_FIELD_CATALOG.
    I_FCAT-FIELDNAME = 'BUKRS'.
      I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '00006'.
      I_FCAT-SELTEXT_L = 'Comp.Code'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'BELNR'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Document No'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'KUNNR'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Customer Code'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'NAME'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000015'.
      I_FCAT-SELTEXT_L = 'Customer Name'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'GJAHR'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000005'.
      I_FCAT-SELTEXT_L = 'Fscl.Yr'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'KOSTL'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000008'.
      I_FCAT-SELTEXT_L = 'Cost Center'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'XBLNR'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000016'.
      I_FCAT-SELTEXT_L = 'Invoice No'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
       I_FCAT-FIELDNAME = 'SGTXT'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '000015'.
      I_FCAT-SELTEXT_L = 'Item Text'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'BUDAT'.
    I_FCAT-OUTPUTLEN = '000015'.
      I_FCAT-SELTEXT_L = 'Posting Date'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'MWSKZ'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '0000010'.
      I_FCAT-SELTEXT_L = 'Tax Code'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'TAXTXT'.
    I_FCAT-HOTSPOT   = 'X'.
      I_FCAT-OUTPUTLEN = '0000015'.
      I_FCAT-SELTEXT_L = 'Tax Description'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'HKONT'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'G/L Account'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'WRBTR'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Net Amount'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'HKONT2'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Tax G/L No.'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'WRBTR2'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Tax Amount'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    I_FCAT-FIELDNAME = 'HKONT1'.
    I_FCAT-HOTSPOT   = 'X'.
    I_FCAT-OUTPUTLEN = '000013'.
      I_FCAT-SELTEXT_L = 'Freight G/L No'.
    I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'WRBTR1'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Freight Amount'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'GROSS'.
    I_FCAT-OUTPUTLEN = '000018'.
      I_FCAT-SELTEXT_L = 'Gross Amount'.
      I_FCAT-DO_SUM = 'X'.
       I_FCAT-cfieldname    = 'PSWSL'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
      I_FCAT-FIELDNAME = 'PSWSL'.
    I_FCAT-OUTPUTLEN = '000018'.
    I_FCAT-OUTPUTLEN = '000004'.
      I_FCAT-SELTEXT_L = 'Curr.'.
      I_FCAT-DO_SUM = 'X'.
      I_FCAT-FIX_COLUMN = 'X'.
      APPEND I_FCAT.
      CLEAR  I_FCAT.
    LS_SORT-UP = 'X'.
      LS_SORT-FIELDNAME = 'BELNR'.
        APPEND LS_SORT TO I_SORT.
        CLEAR LS_SORT.
    LAYOUT-ZEBRA = 'X'.
    ENDFORM.

  • I can not open firefox when I leave the program is tells me that firefox is still running and will not open

    #
    I can not open firefox when I leave the program is tells me that firefox is still running and will not open
    # Details
    BoldItalicInsert a link...

    Because Firefox sucks that way. I have the same problem. Royal pain in the @$$. I have to use the task manager to duck out of it, or you have to w8 & count to 10...lol. Stupid program.

Maybe you are looking for

  • Form created in Pro. Unable to save in reader

    Hello, i've created a form in acrobat pro 9 (trial), and in 8 (no trail) which clients have to fill in and send back (pref. by e-maill). Now i know this is possible with a button. But then the data is send back in xml format and the person who should

  • How achieve "cumulated" key figure in a webi report

    Hi all, In a bex query we can mark "cumulated" in properties of characteristic, then when we run this query  our key figures for this characteristic will be cumulated but for rest of characteristics will be non cumulated values. Please how can I get 

  • Cannot print document - No pages selected - Adobe Reader XI

    Using Adobe Reader XI on a Windows 8.1 machine driving a Brother DCP-7055 printer via a network-linked Windows 7 machine to print 16-page document in Booklet format.  This worked well yesterday, but this morning, with no changes to the system, so far

  • Import Process Slow .. Suggestions for Speedup ?

    Hi, I am doing an import of data from a dump file since the last 15 hours. The size of the database is 15GB on a 10.2.0.3. The majority of the size is in one particular schema. The requirement is to duplicate the schema into a new tablespace. I creat

  • Why are my thumbnails not of the photo?

    When i imported pictures from a disc  into iPhoto, 3 of them do not show the thumbnail of the image but distorted thumbnails of the other images. how do i fix this? they show on the disc as they should and they show on the photographers computer with