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

joe jiang lamp.purl at gmail.com
Thu Jun 12 07:04:38 PDT 2008


sure. for thread, you return || detach. for process, you exit || kill.

On 三, 2008-06-11 at 14:34 +0800, Steven Zhu wrote:
> 我是用perl的线程启动的system调用的bat文件,终止perl的线程,无法终止bat
> 文件的进程吗?
> 
> 在08-6-11,truncatei <truncatei at gmail.com> 写道: 
>         由system调用bat文件启动的进程好像和perl的线程不一样的,不能用
>         这种方法吧
>         
>         2008/6/11 Steven Zhu <stevenzyk at gmail.com>:
>         > 这个是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");
>         > }
>         >
>         >
>         >
>         _______________________________________________
>         China-pm mailing list
>         China-pm at pm.org
>         http://mail.pm.org/mailman/listinfo/china-pm
> 
> 
> 
> -- 
> BR
> Steven.zhu 
> _______________________________________________
> China-pm mailing list
> China-pm at pm.org
> http://mail.pm.org/mailman/listinfo/china-pm



More information about the China-pm mailing list