-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTCL_System.tcl
More file actions
106 lines (90 loc) · 2.98 KB
/
Copy pathTCL_System.tcl
File metadata and controls
106 lines (90 loc) · 2.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#!/bin/sh
# the next line restarts using tclsh \
exec $SPI_PATH/tclsh "$0" "$@"
#============================================================================
# Environnement Canada
# Centre Meteorologique Canadien
# 2100 Trans-Canadienne
# Dorval, Quebec
#
# Projet : Exemple de scripts.
# Fichier : TCL_Vector.tcl
# Creation : Mars 2005 - J.P. Gauthier - CMC/CMOE
# Description: Demonstration de l'usage des appels systeme
#
# Parametres :
#
# Retour:
#
# Remarques :
#
#============================================================================
package require TclSystem
package require Logger
Log::Start [info script] 0.1
set fs [lindex $argv 0]
puts "System info"
puts " name : [system info -name]"
puts " arch : [system info -arch]"
puts " os : [system info -os]"
puts " release : [system info -osrelease]"
puts " version : [system info -osversion]"
puts " nbcpu : [system info -nbcpu]"
puts " uptime : [system info -uptime]"
puts " loads : [system info -loads]"
puts " totalmem : [system info -totalmem]"
puts " freemem : [system info -freemem]"
puts " sharedmem: [system info -sharedmem]"
puts " buffermem: [system info -buffermem]"
puts " totalswap: [system info -totalswap]"
puts " freeswap : [system info -freeswap]"
puts " process : [system info -process]"
puts " totalhigh: [system info -totalhigh]"
puts " freehigh : [system info -freehigh]"
puts " memunit : [system info -memunit]"
puts "\nFile system info for $fs"
puts " Type : [system filesystem $fs -type]"
puts " Blocks : [system filesystem $fs -blocksize -blocks -blockfree -blockused]"
puts " Size : [system filesystem $fs -size]"
puts " Free : [system filesystem $fs -free]"
puts " Used : [system filesystem $fs -used]"
puts " Files : [system filesystem $fs -files]"
puts "\nSystem limit for process"
puts " CPU Time : [system limit -cpu]"
puts " Data size : [system limit -data]"
puts " Stack size : [system limit -stack]"
system limit -stack 3600
puts " Stack new size :[system limit -stack]"
proc ManageSignal { Signal } {
puts "Received signal: $Signal"
}
puts "System signal (pid:[pid])"
puts " Current SIGUSR1 value: [system signal SIGUSR1 -trap ManageSignal]"
puts " Current SIGUSR1 value: [system signal SIGUSR1]"
#----- Fork du process courant
set ppid [pid]
#proc exit { } {
# exec kill [pid]
#}
if { ![set pid [system fork]] } {
puts "Signaling parrent"
after 2000
system signal SIGUSR1 -send $ppid
puts "[pid] Child exiting"
system exit 0
} else {
# system signal SIGKILL -send $pid
puts "Waiting for child process $pid"
system wait $pid
}
#vwait forever
puts "\nSystem usage for process"
after 5000
set calls [list -utime -stime -cutime -cstime -rss -shared -data -stack -minpagefault -majpagefault -swap -inblock -outblock -signal -vcswitch -ivcswitch]
eval set vals \[system usage $calls\]
foreach call $calls val $vals {
puts " $call : $val"
}
#system fork
#system daemonize -lock /tmp/test.pid
Log::End