[PerlChina] 又一问题:如何切换用户权限?

Steven Zhu stevenzyk at gmail.com
Tue Jun 10 22:09:46 PDT 2008


这个是server端的application,程序会有client端发送指令过来,执行bat文件,在执行中再次发送中断指令,停止bat文件的运行,但是目前使用detach中断不了,还是会执行,请帮忙看看
# Server Program
use threads;
use IO::Socket::INET;

print ">> Server Program <<\n";

# Create a new socket
$MySocket=new IO::Socket::INET->new(LocalPort=>1234,Proto=>'udp');
my $new_sock = $MySocket->accept();

# Keep receiving messages from client
while(1)
{
    $MySocket->recv($text,128);
    if ( $text =~ /stop/ )
    {
   open(STOP , "d:\\thread_d");
   while(<STOP>)
   {
    push @child_thread , $_;
   }
   close(STOP);
   $asdf = @child_thread[0];
   print "thread: $asdf\n";
   stop();
    }
    else
    {
     $thread = threads->new(\&start_thread,$MySocket);
     open(THREAD , ">d:\\thread_d");
     print THREAD $thread;
     close(THREAD);
   }
}

sub stop{
 print "thread: $thread\n";
 $qwer = $thread->detach;
 print "$qwer\n";
}

sub start_thread
{
 chdir "F:\\C26_1";
 system("F:\\C26_1\\C26_remake.bat");
}




在08-6-11,truncatei <truncatei at gmail.com> 写道:
>
> 检查一下代码的逻辑看看,或许哪里弄错了。
>
> 2008/6/11 Steven Zhu <stevenzyk at gmail.com>:
> > 现在detach可以起作用了,但是似乎无法终止线程啊
> > 我尝试的例子是把一个正在做copy的线程终止掉,停止copy,但是现在发觉仍然在做啊
> >
> _______________________________________________
> China-pm mailing list
> China-pm at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm




-- 
BR
Steven.zhu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.pm.org/pipermail/china-pm/attachments/20080611/86892b5e/attachment-0001.html 


More information about the China-pm mailing list