ObjFW  Check-in [bdf82f10b4]

Overview
Comment:Add -[OFProcess waitForTermination]
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: bdf82f10b4d5c8baad5d7a7e3a2a03ded501f96d5939411dbed23cb7d40044ee
User & Date: js on 2020-04-26 10:42:17
Other Links: manifest | tags
Context
2020-04-26
10:56
Replace of_socket_address_ipx_get() check-in: 2ff4218405 user: js tags: trunk
10:42
Add -[OFProcess waitForTermination] check-in: bdf82f10b4 user: js tags: trunk
10:06
Make GCC 4.6 happy again check-in: 37e6faa76f user: js tags: trunk
Changes

Modified src/OFProcess.h from [b0e3da0617] to [376740648e].

193
194
195
196
197
198
199







200
201
202
 * @brief Closes the write direction of the process.
 *
 * This method needs to be called for some programs before data can be read,
 * since some programs don't start processing before the write direction is
 * closed.
 */
- (void)closeForWriting;







@end

OF_ASSUME_NONNULL_END







>
>
>
>
>
>
>



193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
 * @brief Closes the write direction of the process.
 *
 * This method needs to be called for some programs before data can be read,
 * since some programs don't start processing before the write direction is
 * closed.
 */
- (void)closeForWriting;

/*!
 * @brief Waits for the process to terminate and returns the exit status.
 *
 * If the process has already exited, this returns the exit status immediately.
 */
- (int)waitForTermination;
@end

OF_ASSUME_NONNULL_END

Modified src/platform/posix/OFProcess.m from [9948874fbd] to [a1d2451059].

373
374
375
376
377
378
379













380
	}

	_pid = -1;
	_readPipe[0] = -1;

	[super close];
}













@end







>
>
>
>
>
>
>
>
>
>
>
>
>

373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
	}

	_pid = -1;
	_readPipe[0] = -1;

	[super close];
}

- (int)waitForTermination
{
	if (_readPipe[0] == -1)
		@throw [OFNotOpenException exceptionWithObject: self];

	if (_pid != -1) {
		waitpid(_pid, &_status, 0);
		_pid = -1;
	}

	return WEXITSTATUS(_status);
}
@end

Modified src/platform/windows/OFProcess.m from [75eaa2091a] to [4f8503117f].

344
345
346
347
348
349
350






















351
	}

	_process = INVALID_HANDLE_VALUE;
	_readPipe[0] = NULL;

	[super close];
}






















@end







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
	}

	_process = INVALID_HANDLE_VALUE;
	_readPipe[0] = NULL;

	[super close];
}

- (int)waitForTermination
{
	if (_readPipe[0] == NULL)
		@throw [OFNotOpenException exceptionWithObject: self];

	if (_process != INVALID_HANDLE_VALUE) {
		DWORD exitCode;

		WaitForSingleObject(_process, INFINITE);

		if (GetExitCodeProcess(_process, &exitCode))
			_status = exitCode;
		else
			_status = GetLastError();

		CloseHandle(_process);
		_process = INVALID_HANDLE_VALUE;
	}

	return _status;
}
@end