public inbox for java-prs@sourceware.org
help / color / mirror / Atom feed
* [Bug libgcj/29324]  New: add wait handling hook
@ 2006-10-02 18:01 tromey at gcc dot gnu dot org
  2006-10-02 18:35 ` [Bug libgcj/29324] " pinskia at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: tromey at gcc dot gnu dot org @ 2006-10-02 18:01 UTC (permalink / raw)
  To: java-prs

Currently libgcj assumes it can waitpid(-1,...).
This interacts poorly with other libraries which may
want to interact with subprocesses; for instance glib
has an API for spawning and waiting for children, and
frysk has to work around this problem (by disallowing
the use of Process).

libgcj ought to have a way to hook into the low-level
process code so that it can interact gracefully with
other libraries.  I think it is ok if this is CNI only.


-- 
           Summary: add wait handling hook
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libgcj
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: tromey at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
@ 2006-10-02 18:35 ` pinskia at gcc dot gnu dot org
  2006-10-02 18:39 ` tromey at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2006-10-02 18:35 UTC (permalink / raw)
  To: java-prs



------- Comment #1 from pinskia at gcc dot gnu dot org  2006-10-02 18:35 -------
Hmnm, is this really a bug, waitpid is used only in the reaper thread.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
  2006-10-02 18:35 ` [Bug libgcj/29324] " pinskia at gcc dot gnu dot org
@ 2006-10-02 18:39 ` tromey at gcc dot gnu dot org
  2006-10-05  5:42 ` daney at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: tromey at gcc dot gnu dot org @ 2006-10-02 18:39 UTC (permalink / raw)
  To: java-prs



------- Comment #2 from tromey at gcc dot gnu dot org  2006-10-02 18:39 -------
Yes, it really is a bug.
libgcj can reap a child process started by some other library.
This means it is hard to use libgcj in conjunction with other libraries
which may want to do their own subprocess bookkeeping.


-- 

tromey at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2006-10-02 18:39:54
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
  2006-10-02 18:35 ` [Bug libgcj/29324] " pinskia at gcc dot gnu dot org
  2006-10-02 18:39 ` tromey at gcc dot gnu dot org
@ 2006-10-05  5:42 ` daney at gcc dot gnu dot org
  2006-10-05  5:48 ` pinskia at physics dot uc dot edu
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: daney at gcc dot gnu dot org @ 2006-10-05  5:42 UTC (permalink / raw)
  To: java-prs



------- Comment #3 from daney at gcc dot gnu dot org  2006-10-05 05:42 -------
One way to fix it would be to have a reaper thread for *each* Process.  Then
the reaper could do a waitpid(pid...) instead of waitpid(-1...).  If one only
spawns a few processes, this would be fine.  This would allow us to get rid of
the SIGCHLD handler as well.

Another option would to have the process reaper be a seperate process, but that
scares me.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
                   ` (2 preceding siblings ...)
  2006-10-05  5:42 ` daney at gcc dot gnu dot org
@ 2006-10-05  5:48 ` pinskia at physics dot uc dot edu
  2006-10-05 17:02 ` daney at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at physics dot uc dot edu @ 2006-10-05  5:48 UTC (permalink / raw)
  To: java-prs



------- Comment #4 from pinskia at physics dot uc dot edu  2006-10-05 05:48 -------
Subject: Re:  add wait handling hook

On Thu, 2006-10-05 at 05:42 +0000, daney at gcc dot gnu dot org wrote:
> 
> ------- Comment #3 from daney at gcc dot gnu dot org  2006-10-05 05:42 -------
> One way to fix it would be to have a reaper thread for *each* Process.  Then
> the reaper could do a waitpid(pid...) instead of waitpid(-1...).  If one only
> spawns a few processes, this would be fine.  This would allow us to get rid of
> the SIGCHLD handler as well.
> 
> Another option would to have the process reaper be a seperate process, but that
> scares me.

Even multiple threads scares me for Linux since that would mean double
the amount of processes in the process table.  Maybe Linux needs this
problem if it still exists.  I know Linux threads had this problem but I
forget if NTPL does.

Thanks,
Andrew Pinski


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
                   ` (3 preceding siblings ...)
  2006-10-05  5:48 ` pinskia at physics dot uc dot edu
@ 2006-10-05 17:02 ` daney at gcc dot gnu dot org
  2006-10-05 17:24 ` daney at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: daney at gcc dot gnu dot org @ 2006-10-05 17:02 UTC (permalink / raw)
  To: java-prs



------- Comment #5 from daney at gcc dot gnu dot org  2006-10-05 17:02 -------
Another idea:

In the SIGCHLD signal handler record the pid of the process that exited.  Then
look it up in the pidToProcess map.  If it belongs to the libgcj runtime, then
do waitpid(pid, ...) on it.  Otherwise ignore it assuming it belongs to code
external to libgcj.  It would be nice if we could call into libgcj from the
signal handler, but I don't think that we can. :(

You could get even fancier and chain the SIGCHLD signal handler to any handler
that may have been previously installed.  We would expect the same of external
code that installed a SIGCHLD handler.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
                   ` (4 preceding siblings ...)
  2006-10-05 17:02 ` daney at gcc dot gnu dot org
@ 2006-10-05 17:24 ` daney at gcc dot gnu dot org
  2007-05-12 17:38 ` daney at gcc dot gnu dot org
  2007-05-12 18:52 ` daney at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: daney at gcc dot gnu dot org @ 2006-10-05 17:24 UTC (permalink / raw)
  To: java-prs



-- 

daney at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |daney at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2006-10-02 18:39:54         |2006-10-05 17:24:32
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
                   ` (5 preceding siblings ...)
  2006-10-05 17:24 ` daney at gcc dot gnu dot org
@ 2007-05-12 17:38 ` daney at gcc dot gnu dot org
  2007-05-12 18:52 ` daney at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: daney at gcc dot gnu dot org @ 2007-05-12 17:38 UTC (permalink / raw)
  To: java-prs



------- Comment #6 from daney at gcc dot gnu dot org  2007-05-12 18:38 -------
Subject: Bug 29324

Author: daney
Date: Sat May 12 17:37:55 2007
New Revision: 124638

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=124638
Log:
        PR libgcj/29324
        * include/posix-threads.h (_Jv_BlockSigchld): Declare.
        (_Jv_UnBlockSigchld): Same.
        * posix-threads.cc: Include posix-threads.h.
        (block_sigchld) Rename to...
        (_Jv_BlockSigchld) ... this.
        (_Jv_UnBlockSigchld): New function.
        (_Jv_InitThreads): Call _Jv_BlockSigchld in place of block_sigchld.
        (_Jv_ThreadStart): Same.
        * java/lang/PosixProcess$ProcessManager.h: Regenerate.
        * java/lang/PosixProcess.java: Clean up imports.
        (ProcessManager): Make final.
        (ProcessManager.queue): Genericise and make private.
        (ProcessManager.pidToProcess): Remove.
        (ProcessManager.liveProcesses): New field.
        (ProcessManager.reaperPID): Remove.
        (ProcessManager.nativeData): New field.
        (ProcessManager.removeProcessFromMap): Remove.
        (ProcessManager.addProcessToMap):Remove.
        (ProcessManager.addToLiveProcesses): New method.
        (ProcessManager.run): Rewritten.
        (ProcessManager.reap): Change method signature,
        (getErrorStream): Correct formatting.
        (getInputStream): Same.
        (spawn): Add process to liveProcesses list.
        (pid): Make package private.
        * java/lang/PosixProcess.h: Regenerate.
        * java/lang/natPosixProcess.cc: Include posix.h and posix-threads.h.
        Add useing namespace java::lang.
        (ProcessManagerInternal): New struct.
        (sigchld_handler): Rewritten.
        (init): Rewritten.
        (waitForSignal): Same.
        (reap): Same.
        (signalReaper): Same.
        (nativeDestroy): Call kill as ::kill.
        (nativeSpawn): Correct formatting.
        * classpath/lib/java/lang/PosixProcess$EOFInputStream.class:
Regenerate.
        * classpath/lib/java/lang/PosixProcess.class: Same.
        * classpath/lib/java/lang/PosixProcess$ProcessManager.class: Same.

Modified:
    trunk/libjava/ChangeLog
    trunk/libjava/classpath/lib/java/lang/PosixProcess$EOFInputStream.class
    trunk/libjava/classpath/lib/java/lang/PosixProcess$ProcessManager.class
    trunk/libjava/classpath/lib/java/lang/PosixProcess.class
    trunk/libjava/include/posix-threads.h
    trunk/libjava/java/lang/PosixProcess$ProcessManager.h
    trunk/libjava/java/lang/PosixProcess.h
    trunk/libjava/java/lang/PosixProcess.java
    trunk/libjava/java/lang/natPosixProcess.cc
    trunk/libjava/posix-threads.cc


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libgcj/29324] add wait handling hook
  2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
                   ` (6 preceding siblings ...)
  2007-05-12 17:38 ` daney at gcc dot gnu dot org
@ 2007-05-12 18:52 ` daney at gcc dot gnu dot org
  7 siblings, 0 replies; 9+ messages in thread
From: daney at gcc dot gnu dot org @ 2007-05-12 18:52 UTC (permalink / raw)
  To: java-prs



------- Comment #7 from daney at gcc dot gnu dot org  2007-05-12 19:52 -------
I think the patch solves the problem.


-- 

daney at gcc dot gnu dot org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.3.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=29324


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2007-05-12 18:52 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-10-02 18:01 [Bug libgcj/29324] New: add wait handling hook tromey at gcc dot gnu dot org
2006-10-02 18:35 ` [Bug libgcj/29324] " pinskia at gcc dot gnu dot org
2006-10-02 18:39 ` tromey at gcc dot gnu dot org
2006-10-05  5:42 ` daney at gcc dot gnu dot org
2006-10-05  5:48 ` pinskia at physics dot uc dot edu
2006-10-05 17:02 ` daney at gcc dot gnu dot org
2006-10-05 17:24 ` daney at gcc dot gnu dot org
2007-05-12 17:38 ` daney at gcc dot gnu dot org
2007-05-12 18:52 ` daney at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).