Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1228294

(fp.bugs 2334) Opening a unix special file fifo will block all threads

    XMLWordPrintable

Details

    • sparc
    • solaris_2.4

    Description

      From: ###@###.###

      Opening a unix special file fifo will block all threads if
      no one has the file open for writing.

      import java.io.*;
      import java.lang.*;
      import java.util.*;
      public class FifoReader extends Thread {
           FileInputStream infile = null;
           String FifoName = null;
           DataInputStream ds = null;

           FifoReader(String filename) {
              FifoName = new String(filename);
           }

           String GetTranData() {
                String ret = null;
                try {
                     System.out.println("Reading...");
                     ret = ds.readLine();
                     return (ret);
                }
                catch (IOException e) {
                     System.out.println("Exception" + e.getMessage());
                     return new String("Could not get line");
                }
           }

           public void run() {
              Thread.currentThread().setName(FifoName);
              this.yield(); // This allows the other thread to catch up
              System.out.println("Opening the fifo for read");

              try {
                 infile = new FileInputStream(FifoName);
                 ds = new DataInputStream(infile);
              }
              catch ( FileNotFoundException e) {
                 System.out.println("Exception"
                           + e.getMessage());
                 stop();
              }
              System.out.println("Ready to read");
              while (true) {
                 PrintLine();
              }
           }
           void PrintLine() {
              System.out.println("Line: " + GetTranData());
           }

           public static void main(String argv[] )
             throws FileNotFoundException
           {
              FifoReader F = new FifoReader("foo");
              FifoReader X = new FifoReader("bar");
              X.start();
              F.start();
           }
      }
           

      Full thread dump:
          "foo" (TID:0xee3004a0, sys_thread_t:0xef470de8) prio=5
           FifoReader.run(FifoReader.java:41)
          "bar" (TID:0xee300508, sys_thread_t:0xef4a0de8) prio=5 *current thread*
           java.io.FileInputStream.<init>(FileInputStream.java)
           FifoReader.run(FifoReader.java:45)
          "Finalizer thread" (TID:0xee300358, sys_thread_t:0xef4d0de8) prio=1
          "Async Garbage Collector" (TID:0xee300308, sys_thread_t:0xef500de8)
      prio=1
          "Idle thread" (TID:0xee300290, sys_thread_t:0xef530de8) prio=0
          "clock handler" (TID:0xee300098, sys_thread_t:0xef5f0de8) prio=11
          "main" (TID:0xee300048, sys_thread_t:0x7ca78) prio=5
      Monitor Cache Dump:

      Attachments

        Activity

          People

            duke J. Duke
            hwilliamsunw Headley Williamson (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: