FVWM: Threading.

From: Rusty Phillips <rustyp_at_freeshell.org>
Date: Wed, 07 Jul 2004 10:18:41 -0500

I don't think detach works the way it should for me. Any time you
execute "exit" anywhere in any thread (when forking - whether I fork or
FvwmPerl does), all threads exit in FvwmPerl. This isn't what we want,
is it?

So far I have two solutions to this:
1) Have the process kill itself when it finishes.
2) Use perlthreads (using either the "threads" package or the "forks"
package) and detach the process

In the interest of not using extra Perl packages when I wasn't using a
module, I implemented solution #1.
I had a bit of trouble actually getting the PID of the child process
from itself. For some reason, $$ maps to fvwm rather than the child
process.
I had to either use Linux::Pid, or make a shell call.

Of course, a better solution to all this would be to figure out whats
wrong with FvwmPerl's exit and fix it so that detach works (I'm testing
with FvwmPerl from CVS from June 30, btw).

I put a lock on xwd usage. A lot of this is an ugly hack. But the
beauty is that it works, and I didn't have to implement another module.

So...here you go.

DestroyFunc CaptureIcon
AddToFunc CaptureIcon
+ I raise
+ I eval \
    $g=1 if(!$g=~/0|1/); \
    while($g==0) { } \
    $g=0;\
    $e{$[w.id]} =`xwd -silent -id $[w.id] 2>&1`; \
    $g=1;\
    if(substr($e{$[w.id]},0,10)=~/Error/) { \
    for(my $i=0; $i<8; $i++) \
    { \
        $e{$[w.id]} = `xwd -silent -id $[w.id]`; \
        last if(!(substr($e{$[w.id]},0,10)=~/Error/)); \
    } } \
    $f{$[w.id]}=1;

DestroyFunc UseCaptured
AddToFunc UseCaptured
+ I eval my $pid; $SIG{'CHLD'}='IGNORE'; if(!($pid=fork)) { \
        $pid=`echo $$$$$$$$`; \
    setpriority 0,0,19; \
    while (!exists($f{$[w.id]})) { }; \
    open(TEMP12, "|convert -scale $[fvwm_icon_size] -frame 1x1 \
    -mattecolor black -quality 0 xwd:- \
    png:$[HOME]/.fvwm/icon.tmp.$[w.id].png"); \
print TEMP12 $e{$[w.id]}; close(TEMP12); \
cmd("WindowId $[w.id] WindowStyle IconOverride, \
     Icon $[HOME]/.fvwm/icon.tmp.$[w.id].png, StaysOnBottom"); \
     delete $e{$[w.id]}; \
     delete $f{$[w.id]}; \
     kill 9,$pid; \
    };

DestroyFunc FastThumb
AddToFunc FastThumb
+ I CaptureIcon
+ I Iconify
+ I UseCaptured

--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Wed Jul 07 2004 - 10:06:35 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:56 BST