On Fri, Sep 05, 2008 at 10:41:07AM -0500, Hal Duston wrote:
On Fri, Sep 05, 2008 at 09:27:13AM -0500, Monty J. Harder wrote:
Yes, they exec to spawn these separate processes. But those processes can't change the arguments under which they were invoked without themselves exec-ing all over again. So when you click on a "Heh.", you'd have to change one process from monster 3952 26665 0 10:08 ? /usr/lib/firefox-4.0/firefox-bin -UILocale en-US instapundit.com to monster 3952 26665 0 10:08 ? /usr/lib/firefox-4.0/firefox-bin -UILocale en-US johndoe.blogspot.com/2008/09/snarky-article-title-here.html
The only way I know to do that is to exec firefox-bin, invoking the new URL as an argument. What I don't know is how much overhead that takes. I suppose a stripped-down binary, that inherits a pre-built environment populated by another binary reading configs, etc., might not be doable.
But that's not the way that any existing browser I know of is written. You're talking about a complete re-factoring of how browsers work. That's not to say that it's a bad idea, just that it's a non-trivial effort, which might make things much slower
A process can change the arguments at any time w/o doing an exec. I have actually read the code that is needed to do this under Linux. It is less than 15 lines. All it does is rebuild the environment which is where the exec'ed command line arguments are kept. Once they are rebuilt ps, top, and everything else just pick them up from /proc/<pid>/cmdline.
A quick example I threw together in just a few minutes:
$ wc -l xxq.c 71 xxq.c $ ./xxq "This process changed its arguments" & ps -f [1] 1524 UID PID PPID C STIME TTY TIME CMD hald 1524 32251 0 11:12 pts/7 00:00:00 This process changed its arguments $ ./xxq "This process changed its parameters" & ps -f [2] 1532 UID PID PPID C STIME TTY TIME CMD hald 1532 32251 0 11:13 pts/7 00:00:00 This process changed its parameters
Thanks,
Hal