ObjFW  Check-in [67df0aa735]

Overview
Comment:OFProcess: Initialize to invalid handles first

The reason for this is that if anything fails during init, close is
called on dealloc and we want it to be in a sane state for that.

Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 67df0aa7355cecb082ae8e6ac7aa87f3a2009df458ff0fc7e07d3284bef34a05
User & Date: js on 2020-04-24 22:42:55
Other Links: manifest | tags
Context
2020-04-25
13:40
Remove OFIPStreamSocket check-in: 424fb54efd user: js tags: trunk
2020-04-24
22:42
OFProcess: Initialize to invalid handles first check-in: 67df0aa735 user: js tags: trunk
00:21
Add OFIPStreamSocket check-in: 3dfe642dd3 user: js tags: trunk
Changes

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

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

Modified src/platform/windows/OFProcess.m from [0696e641e7] to [75eaa2091a].

115
116
117
118
119
120
121



122
123
124
125
126
127
128
		PROCESS_INFORMATION pi;
		STARTUPINFOW si;
		void *pool;
		OFMutableString *argumentsString;
		of_char16_t *argumentsCopy;
		size_t length;




		sa.nLength = sizeof(sa);
		sa.bInheritHandle = TRUE;
		sa.lpSecurityDescriptor = NULL;

		if (!CreatePipe(&_readPipe[0], &_readPipe[1], &sa, 0))
			@throw [OFInitializationFailedException
			    exceptionWithClass: self.class];







>
>
>







115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
		PROCESS_INFORMATION pi;
		STARTUPINFOW si;
		void *pool;
		OFMutableString *argumentsString;
		of_char16_t *argumentsCopy;
		size_t length;

		_process = INVALID_HANDLE_VALUE;
		_readPipe[0] = _writePipe[1] = NULL;

		sa.nLength = sizeof(sa);
		sa.bInheritHandle = TRUE;
		sa.lpSecurityDescriptor = NULL;

		if (!CreatePipe(&_readPipe[0], &_readPipe[1], &sa, 0))
			@throw [OFInitializationFailedException
			    exceptionWithClass: self.class];