[PerlChina] 又一问题:如何切换用户权限?
truncatei
truncatei at gmail.com
Tue Jun 10 22:23:48 PDT 2008
由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");
> }
>
>
>
More information about the China-pm
mailing list