Property definitions

core $ NativeProcess :: defaultinit
private extern class NativeProcess `{ se_exec_data_t* `}

	fun id: Int `{ return (long)self->id; `}
	fun status: Int `{ return self->status; `}
	fun in_fd: Int `{ return self->in_fd; `}
	fun out_fd: Int `{ return self->out_fd; `}
	fun err_fd: Int `{ return self->err_fd; `}

	fun is_finished: Bool `{
		int result = (int)0;
		if (self->running) {
#ifdef _WIN32
			if (WaitForSingleObject(self->h_process, 0) == 0) {
				/* child is finished */
				result = 1;

				long unsigned int status;
				GetExitCodeProcess(self->h_process, &status);
				self->running = 0;
				self->status = (int)status;

				CloseHandle(self->h_process);
				CloseHandle(self->h_thread);
			}
#else
			int status;
			int id = waitpid(self->id, &status, WNOHANG);
			if (id != 0) {
				/* child is finished */
				result = (int)(id == self->id);
				self->status = WEXITSTATUS(status);
				self->running = 0;
			}
#endif
		}
		else{
			result = (int)1;
		}
		return result;
	`}

	fun wait `{
#ifdef _WIN32
		long unsigned int status;
		if (self->running) {
			WaitForSingleObject(self->h_process, INFINITE);
			GetExitCodeProcess(self->h_process, &status);

			CloseHandle(self->h_process);
			CloseHandle(self->h_thread);

			self->status = (int)status;
			self->running = 0;
		}
#else
		int status;
		if (self->running) {
			waitpid(self->id, &status, 0);
			self->status = WEXITSTATUS(status);
			self->running = 0;
		}
#endif
	`}
end
lib/core/exec.nit:477,1--540,3