This is the mail archive of the java-patches@gcc.gnu.org mailing list for the Java project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: RFA PATCH: Fix PosixProcess some more...


David Daney wrote:
> 
> I will prepare new versions of the patches now.
> 

Here they are.

Currently in make check.

O.K. to commit if no regressions?

David Daney.
2004-08-17  David Daney  <ddaney@avtrex.com>

	* java/lang/natPosixProcess.cc (waitForSignal): Use sigsuspend
	instead of sigwait.

Index: java/lang/natPosixProcess.cc
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/lang/natPosixProcess.cc,v
retrieving revision 1.19
diff -c -p -r1.19 natPosixProcess.cc
*** java/lang/natPosixProcess.cc	12 Aug 2004 16:20:11 -0000	1.19
--- java/lang/natPosixProcess.cc	18 Aug 2004 00:02:58 -0000
*************** java::lang::ConcreteProcess$ProcessManag
*** 128,149 ****
  {
    using namespace java::lang;
  
!   sigset_t mask;
    // Wait for SIGCHLD
    sigemptyset (&mask);
!   sigaddset (&mask, SIGCHLD);
  
!   int sig;
!   int c = sigwait (&mask, &sig);
! 
!   if (c != 0)
      goto error;
  
    // All OK.
    return;
  
  error:
!   throw new InternalError (JvNewStringUTF (strerror (c)));
  }
  
  jboolean java::lang::ConcreteProcess$ProcessManager::reap ()
--- 128,152 ----
  {
    using namespace java::lang;
  
!   sigset_t mask, new_mask;
    // Wait for SIGCHLD
    sigemptyset (&mask);
!   pthread_sigmask (SIG_BLOCK, &mask, &new_mask);
!   sigdelset (&new_mask, SIGCHLD);
!   // Use sigsuspend() instead of sigwait() as sigwait() doesn't play
!   // nicely with the GC's use of signals.
!   int c = sigsuspend (&new_mask);
  
!   if (c != -1)
!     goto error;
!   if (errno != EINTR)
      goto error;
  
    // All OK.
    return;
  
  error:
!   throw new InternalError (JvNewStringUTF (strerror (errno)));
  }
  
  jboolean java::lang::ConcreteProcess$ProcessManager::reap ()
2004-08-17  David Daney  <ddaney@avtrex.com>

	* testsuite/libjava.lang/Process_7.java: New test.
	* testsuite/libjava.lang/Process_7.out: Expected output.

Index: testsuite/libjava.lang/Process_7.java
===================================================================
RCS file: testsuite/libjava.lang/Process_7.java
diff -N testsuite/libjava.lang/Process_7.java
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/libjava.lang/Process_7.java	18 Aug 2004 00:04:09 -0000
***************
*** 0 ****
--- 1,50 ----
+ // Create a long running Process.  Verify that the garbage collector
+ // can run and that it does not interfere with the Process.
+ public class Process_7 implements Runnable
+ {
+   public void run()
+   {
+     try
+       {
+         Runtime r = Runtime.getRuntime();
+         String[] a = { "sleep", "10"};
+         Process p = r.exec(a);
+         int rc = p.waitFor();
+         if(rc == 0)
+           System.out.println("ok");
+         else
+           System.out.println("bad 1");
+       }
+     catch (Exception ex)
+       {
+         ex.printStackTrace();
+       }
+   }
+ 
+   public static void main(String args[])
+   {
+     try
+       {
+         Process_7 p = new Process_7();
+         Thread t = new Thread(p);
+         t.start();
+         long elapsed = 0;
+         for (int i = 0; i < 10; i++)
+           {
+             Thread.sleep(1000);
+             long s = System.currentTimeMillis();
+             System.gc();
+             long e = System.currentTimeMillis();
+             elapsed += (e - s);
+           }
+         if (elapsed > 5000)
+           System.out.println("bad 2");
+         else
+           System.out.println("ok");
+       }
+     catch (Exception ex)
+       {
+         ex.printStackTrace();
+       }
+   }
+ }
Index: testsuite/libjava.lang/Process_7.out
===================================================================
RCS file: testsuite/libjava.lang/Process_7.out
diff -N testsuite/libjava.lang/Process_7.out
*** /dev/null	1 Jan 1970 00:00:00 -0000
--- testsuite/libjava.lang/Process_7.out	18 Aug 2004 00:04:09 -0000
***************
*** 0 ****
--- 1,2 ----
+ ok
+ ok

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]