Comment 2 for bug 904448

Revision history for this message
Kevin Cox (kevincox) wrote :

I don't know much about scribes' internals but I can see two ways that might work.

I way is to start an independant scribes process that will not fork and all the other windows/documents use the main thread. Then when that window closes the secondary thread closes and returns. This is similar to how firefox works. If you open firefox it will try to open a new window on an existing session in which case it returns right away. If there is no session open it starts one and blocks untill all windows in that session are closed.

But, if you start firefox with -no-remote and a new profile (only one instance per profile is allowed) it opens a new session and blocks untill all windows in that session are closed.

The limitations of this meathod are larger memory usage, you can't switch to and from the seperate document to others and a higher memory useage. You might also have a problem with settings depending on how they are implemented.

The other meathod is a lot more elegant.

If scribes is started with the appropriate flags, after it sends a signal to start a new process it relaces (exec) it's process with a process which just blocks untill it gets a signal (USR1) at which point it closes. Then you have with each document an associated pid of that blocker (or 0 if there is no blocker) and when that document is closed you send the signal to the blocker and it returns.

The problems with this meathod is that I have no clue how signals (or the equivilent) are done in windows so you may have to have a sperate launcher for windows and the unixes. Also, I am not sure wether python has an exec statement like the C one that replaces the currently running binary with another.

These are just thoughts, I haven't done anything like this before.