Check-in [55756e0014]
Overview
SHA1:55756e001412ffc33739ca8d4b1bc1f179e43f2a
Date: 2014-11-03 17:15:27
User: rkeene
Comment:Added UNIX command-workalikes for dmesg/ulimit
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2014-11-03
18:00
[e28b7fa02d] Work towards a better ifconfig interface (user: rkeene, tags: trunk)
17:15
[55756e0014] Added UNIX command-workalikes for dmesg/ulimit (user: rkeene, tags: trunk)
16:34
[9b491cd779] Implemented rlimit and klogctl (user: rkeene, tags: trunk)
Changes

Modified tuapi.tcl from [01f421e4ee] to [271a0d4ae4].

   550    550   					close $fd
   551    551   				}
   552    552   			}
   553    553   
   554    554   			puts [format $format $pidinfo(uid) $pidinfo(pid) $pidinfo(ppid) $pidinfo(cpuutil) $pidinfo(starttime) $pidinfo(tty) $pidinfo(cputime) $pidinfo(cmd)]
   555    555   		}
   556    556   	}
          557  +
          558  +	proc ::dmesg {} {
          559  +		puts [::tuapi::syscall::klogctl read]
          560  +	}
          561  +
          562  +	proc ::ulimit {limit {val ""}} {
          563  +		set mapping(-c) [list CORE]
          564  +		set mapping(-d) [list DATA]
          565  +		set mapping(-e) [list NICE]
          566  +		set mapping(-f) [list FSIZE]
          567  +		set mapping(-i) [list SIGPENDING]
          568  +		set mapping(-l) [list MEMLOCK]
          569  +		set mapping(-m) [list RSS]
          570  +		set mapping(-n) [list NOFILE]
          571  +		set mapping(-q) [list MSGQUEUE]
          572  +		set mapping(-r) [list RTPRIO]
          573  +		set mapping(-s) [list STACK]
          574  +		set mapping(-t) [list CPU]
          575  +		set mapping(-u) [list NPROC]
          576  +		set mapping(-v) [list AS]
          577  +		set mapping(-x) [list LOCKS]
          578  +		set help(CORE) {core file size          (blocks, -c)}
          579  +		set help(DATA) {data seg size           (kbytes, -d)}
          580  +		set help(NICE) {scheduling priority             (-e)}
          581  +		set help(FSIZE) {file size               (blocks, -f)}
          582  +		set help(SIGPENDING) {pending signals                 (-i)}
          583  +		set help(MEMLOCK) {max locked memory       (kbytes, -l)}
          584  +		set help(RSS) {max memory size         (kbytes, -m)}
          585  +		set help(NOFILE) {open files                      (-n)}
          586  +		set help(-p) {pipe size            (512 bytes, -p)}
          587  +		set help(MSGQUEUE) {POSIX message queues     (bytes, -q)}
          588  +		set help(RTPRIO) {real-time priority              (-r)}
          589  +		set help(STACK) {stack size              (kbytes, -s)}
          590  +		set help(CPU) {cpu time               (seconds, -t)}
          591  +		set help(NPROC) {max user processes              (-u)}
          592  +		set help(AS) {virtual memory          (kbytes, -v)}
          593  +		set help(LOCKS) {file locks                      (-x)}
          594  +
          595  +		foreach {limitopt limitoptvals} [array get mapping] {
          596  +			foreach limitoptval $limitoptvals {
          597  +				lappend mapping(-a) $limitoptval
          598  +			}
          599  +		}
          600  +
          601  +		set opts $mapping($limit)
          602  +
          603  +		if {[llength $opts] != 1 && $val != ""} {
          604  +			return -code error "Unable to set multiple limits"
          605  +		}
          606  +
          607  +		foreach opt $opts {
          608  +			unset -nocomplain optval
          609  +
          610  +			if {$val != ""} {
          611  +				catch {
          612  +					::tuapi::syscall::rlimit set $opt $val
          613  +				}
          614  +				set include_help ""
          615  +			} else {
          616  +				set include_help "$help($opt) "
          617  +			}
          618  +
          619  +			catch {
          620  +				set optval [::tuapi::syscall::rlimit get $opt]
          621  +			}
          622  +
          623  +			if {![info exists optval]} {
          624  +				continue
          625  +			}
          626  +
          627  +			puts "${include_help}$optval"
          628  +		}
          629  +	}
   557    630   }