• R/O
  • SSH

kink: Commit

Kink runtime


Commit MetaInfo

Revision071b3392e777d7564960793027a9e3946080b163 (tree)
Time2020-06-30 23:17:03
Authormiyakawataku
Commitermiyakawataku

Log Message

add PROCESS.pid

Change Summary

Incremental Difference

diff -r 24b0a0b08303 -r 071b3392e777 src/main/resources/kink-mods/kink/PROCESS.kn
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/main/resources/kink-mods/kink/PROCESS.kn Tue Jun 30 23:17:03 2020 +0900
@@ -0,0 +1,22 @@
1+##
2+# Control the current and child processes.
3+
4+:JAVA.require_from('kink/javahost/')
5+:ProcessHandle_class <- JAVA.class('java.lang.ProcessHandle')
6+
7+## PROCESS.pid
8+#
9+# `pid` returns the current process id in an int num.
10+#
11+# Example:
12+#
13+# :PROCESS.require_from('kink/')
14+#
15+# stdout.print_line(PROCESS.pid.repr) # => 123
16+:pid <- {()
17+ :Cur_process_handle = ProcessHandle_class.call_static('current' [])
18+ :Pid_long = Cur_process_handle.call_method('pid' [])
19+ Pid_long.to_kink_num
20+}
21+
22+# vim: et sw=2 sts=2 fdm=marker
diff -r 24b0a0b08303 -r 071b3392e777 src/test/kink/PROCESS_test.kn
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/test/kink/PROCESS_test.kn Tue Jun 30 23:17:03 2020 +0900
@@ -0,0 +1,12 @@
1+:PROCESS.require_from('kink/')
2+:NUM.require_from('kink/')
3+:TEST.require_from('kink/test/')
4+
5+TEST.group('PROCESS.pid'){
6+ TEST.test('returns int num'){
7+ :Pid = PROCESS.pid
8+ NUM.is?(Pid) && Pid.int? || raise('got {}'.format(Pid.repr))
9+ }
10+}
11+
12+# vim: et sw=2 sts=2 fdm=marker
Show on old repository browser