ObjFW  Check-in [382e89a033]

Overview
Comment:OFProcess: Kill the process in -[close].
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 382e89a033c2227b88f98998a230202c87eb14184568b24fa9b224df81a6598d
User & Date: js on 2013-01-08 03:41:59
Other Links: manifest | tags
Context
2013-01-08
12:33
OFString: Add methods for UTF-32. check-in: 7cddd5f891 user: js tags: trunk
03:41
OFProcess: Kill the process in -[close]. check-in: 382e89a033 user: js tags: trunk
03:13
OFTCPSocket+SOCKS5: Don't send in native encoding. check-in: 6bd1d03cc1 user: js tags: trunk
Changes

Modified src/OFProcess.h from [1b4bac3eb9] to [f6205ef845].

38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 */
@interface OFProcess: OFStream
{
#ifndef _WIN32
	pid_t pid;
	int readPipe[2], writePipe[2];
#else
	HANDLE readPipe[2], writePipe[2];
#endif
	int status;
	BOOL atEndOfStream;
}

/*!
 * @brief Creates a new OFProcess with the specified program and invokes the







|







38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
 */
@interface OFProcess: OFStream
{
#ifndef _WIN32
	pid_t pid;
	int readPipe[2], writePipe[2];
#else
	HANDLE process, readPipe[2], writePipe[2];
#endif
	int status;
	BOOL atEndOfStream;
}

/*!
 * @brief Creates a new OFProcess with the specified program and invokes the

Modified src/OFProcess.m from [3b9c1e042c] to [d218abb29b].

17
18
19
20
21
22
23

24
25
26
27
28
29
30
#include "config.h"

#include <stdlib.h>
#include <string.h>

#ifndef _WIN32
# include <unistd.h>

# include <sys/wait.h>
#endif

#ifdef __MACH__
# include <crt_externs.h>
#endif








>







17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include "config.h"

#include <stdlib.h>
#include <string.h>

#ifndef _WIN32
# include <unistd.h>
# include <signal.h>
# include <sys/wait.h>
#endif

#ifdef __MACH__
# include <crt_externs.h>
#endif

258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
				    exceptionWithClass: [self class]];
		} @finally {
			[self freeMemory: argumentsCopy];
		}

		objc_autoreleasePoolPop(pool);

		CloseHandle(pi.hProcess);
		CloseHandle(pi.hThread);

		CloseHandle(readPipe[1]);
		CloseHandle(writePipe[0]);
#endif
	} @catch (id e) {
		[self release];







|







259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
				    exceptionWithClass: [self class]];
		} @finally {
			[self freeMemory: argumentsCopy];
		}

		objc_autoreleasePoolPop(pool);

		process = pi.hProcess;
		CloseHandle(pi.hThread);

		CloseHandle(readPipe[1]);
		CloseHandle(writePipe[0]);
#endif
	} @catch (id e) {
		[self release];
458
459
460
461
462
463
464
465

466

467
468
469
470
471
472
473
474
475
476






477
478
479
480
481
{
#ifndef _WIN32
	if (readPipe[0] != -1)
		close(readPipe[0]);
	if (writePipe[1] != -1)
		close(writePipe[1]);

	if (pid != -1)

		waitpid(pid, &status, WNOHANG);


	pid = -1;
	readPipe[0] = -1;
	writePipe[1] = -1;
#else
	if (readPipe[0] != NULL)
		CloseHandle(readPipe[0]);
	if (writePipe[1] != NULL)
		CloseHandle(writePipe[1]);







	readPipe[0] = NULL;
	writePipe[1] = NULL;
#endif
}
@end







|
>

>










>
>
>
>
>
>





459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
{
#ifndef _WIN32
	if (readPipe[0] != -1)
		close(readPipe[0]);
	if (writePipe[1] != -1)
		close(writePipe[1]);

	if (pid != -1) {
		kill(pid, SIGKILL);
		waitpid(pid, &status, WNOHANG);
	}

	pid = -1;
	readPipe[0] = -1;
	writePipe[1] = -1;
#else
	if (readPipe[0] != NULL)
		CloseHandle(readPipe[0]);
	if (writePipe[1] != NULL)
		CloseHandle(writePipe[1]);

	if (process != INVALID_HANDLE_VALUE) {
		TerminateProcess(process, 0);
		CloseHandle(process);
	}

	process = INVALID_HANDLE_VALUE;
	readPipe[0] = NULL;
	writePipe[1] = NULL;
#endif
}
@end