OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [perl_gui/] [lib/] [perl/] [temp.pl] - Blame information for rev 41

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 25 alirezamon
#!/usr/bin/perl
2 38 alirezamon
 
3
 
4
use strict;
5 25 alirezamon
use warnings;
6 41 alirezamon
use Gtk2;
7
use Time::HiRes qw( usleep ualarm gettimeofday tv_interval nanosleep  clock_gettime clock_getres clock_nanosleep clock stat );
8
use Proc::Background;
9
use IO::CaptureOutput qw(capture qxx qxy);
10 24 alirezamon
 
11 41 alirezamon
$ENV{TEMP}="ALIREZA";
12
 
13
 
14
my $cmd =       "xterm -e sh  t.sh";
15
my ($stdout,$exit)=run_cmd_in_back_ground_get_stdout( $cmd);
16
 
17
 
18
 
19
##########
20
#  run external commands
21
##########
22
 
23
sub run_cmd_in_back_ground
24
{
25
  my $command = shift;
26
  #print "\t$command\n";
27
 
28
  ### Start running the Background Job:
29
    my $proc = Proc::Background->new($command);
30
    my $PID = $proc->pid;
31
    my $start_time = $proc->start_time;
32
    my $alive = $proc->alive;
33
 
34
  ### While $alive is NOT '0', then keep checking till it is...
35
  #  *When $alive is '0', it has finished executing.
36
  while($alive ne 0)
37
  {
38
    $alive = $proc->alive;
39
 
40
    # This while loop will cause Gtk2 to conti processing events, if
41
    # there are events pending... *which there are...
42
    while (Gtk2->events_pending) {
43
      Gtk2->main_iteration;
44
    }
45
    Gtk2::Gdk->flush;
46
 
47
    usleep(1000);
48
  }
49
 
50
  my $end_time = $proc->end_time;
51
 # print "*Command Completed at $end_time, with PID = $PID\n\n";
52
 
53
  # Since the while loop has exited, the BG job has finished running:
54
  # so close the pop-up window...
55
 # $popup_window->hide;
56
 
57
  # Get the RETCODE from the Background Job using the 'wait' method
58
  my $retcode = $proc->wait;
59
  $retcode /= 256;
60
 
61
  print "\t*RETCODE == $retcode\n\n";
62
  Gtk2::Gdk->flush;
63
  ### Check if the RETCODE returned with an Error:
64
  if ($retcode ne 0) {
65
    print "Error: The Background Job ($command) returned with an Error...!\n";
66
    return 1;
67
  } else {
68
    #print "Success: The Background Job Completed Successfully...!\n";
69
    return 0;
70
  }
71
 
72
}
73
 
74
 
75
 
76
sub run_cmd_in_back_ground_get_stdout
77
{
78
        my $cmd=shift;
79
        my $exit;
80
        my ($stdout, $stderr);
81
        capture { $exit=run_cmd_in_back_ground($cmd) } \$stdout, \$stderr;
82
        return ($stdout,$exit,$stderr);
83
 
84
}
85
 
86
 
87
 
88
 
89
 
90
 
91
 
92
#system ("sh t.sh");

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.