mirror of
				https://github.com/janet-lang/janet
				synced 2025-10-30 23:23:07 +00:00 
			
		
		
		
	Add os/getpid
This commit is contained in:
		| @@ -4466,7 +4466,7 @@ | ||||
|  | ||||
|   (defn bundle/add | ||||
|     "Add files and directories during a bundle install relative to `(dyn *syspath*)`. | ||||
|      Added paths will be recorded in the bundle manifest such that they are properly tracked | ||||
|      Added files and directories will be recorded in the bundle manifest such that they are properly tracked | ||||
|      and removed during an upgrade or uninstall." | ||||
|     [manifest src &opt dest chmod-mode] | ||||
|     (default dest src) | ||||
|   | ||||
| @@ -813,6 +813,18 @@ JANET_CORE_FN(os_proc_close, | ||||
| #endif | ||||
| } | ||||
|  | ||||
| JANET_CORE_FN(os_proc_getpid, | ||||
|         "(os/getpid)", | ||||
|         "Get the process ID of the current process.") { | ||||
|     janet_fixarity(argc, 0); | ||||
|     (void) argv; | ||||
| #ifdef JANET_WINDOWS | ||||
|     return janet_wrap_number((double) _getpid()); | ||||
| #else | ||||
|     return janet_wrap_number((double) getpid()); | ||||
| #endif | ||||
| } | ||||
|  | ||||
| static void swap_handles(JanetHandle *handles) { | ||||
|     JanetHandle temp = handles[0]; | ||||
|     handles[0] = handles[1]; | ||||
| @@ -2797,6 +2809,7 @@ void janet_lib_os(JanetTable *env) { | ||||
|         JANET_CORE_REG("os/proc-wait", os_proc_wait), | ||||
|         JANET_CORE_REG("os/proc-kill", os_proc_kill), | ||||
|         JANET_CORE_REG("os/proc-close", os_proc_close), | ||||
|         JANET_CORE_REG("os/getpid", os_proc_getpid), | ||||
| #endif | ||||
|  | ||||
|         /* high resolution timers */ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Calvin Rose
					Calvin Rose