ObjFW  Diff

Differences From Artifact [bd118b08f1]:

To Artifact [a1d2451059]:


127
128
129
130
131
132
133



134
135
136
137
138
139
140
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		const char *path;
		char **argv;




		if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0)
			@throw [OFInitializationFailedException
			    exceptionWithClass: self.class];

		path = [program cStringWithEncoding: [OFLocale encoding]];
		[self of_getArgv: &argv
		  forProgramName: programName







>
>
>







127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
	self = [super init];

	@try {
		void *pool = objc_autoreleasePoolPush();
		const char *path;
		char **argv;

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

		if (pipe(_readPipe) != 0 || pipe(_writePipe) != 0)
			@throw [OFInitializationFailedException
			    exceptionWithClass: self.class];

		path = [program cStringWithEncoding: [OFLocale encoding]];
		[self of_getArgv: &argv
		  forProgramName: programName
370
371
372
373
374
375
376













377
	}

	_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