ObjFW  Check-in [6ca56b4f15]

Overview
Comment:OFSubprocess: Correctly handle nil environment
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 6ca56b4f15f819dc4bdf1f9cb60b987474a35bc0e8b8c8b0ca28aebe9830ff65
User & Date: js on 2024-01-21 09:38:51
Other Links: manifest | tags
Context
2024-01-21
09:55
OFSubprocess: Fix dealloc after -[closeForWriting] check-in: 3f56716b3d user: js tags: trunk
09:39
OFSubprocess: Correctly handle nil environment check-in: c9125d25d4 user: js tags: 1.0
09:38
OFSubprocess: Correctly handle nil environment check-in: 6ca56b4f15 user: js tags: trunk
2024-01-20
21:40
Add support for LOC DNS resource records check-in: d37c636a61 user: js tags: trunk
Changes

Modified src/platform/POSIX/OFSubprocess.m from [6b69aef5c9] to [de1f50a841].

174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189

190
191
192
193
194
195
196
197
				if (posix_spawnattr_setflags(&attr,
				    POSIX_SPAWN_CLOEXEC_DEFAULT) != 0)
					@throw [OFInitializationFailedException
					    exceptionWithClass: self.class];
# endif

				if (posix_spawnp(&_pid, path, &actions, &attr,
				    argv, env) != 0)
					@throw [OFInitializationFailedException
					    exceptionWithClass: self.class];
			} @finally {
				posix_spawn_file_actions_destroy(&actions);
				posix_spawnattr_destroy(&attr);
			}
#else
			if ((_pid = vfork()) == 0) {

				environ = env;

				close(_readPipe[0]);
				close(_writePipe[1]);
				dup2(_writePipe[0], 0);
				dup2(_readPipe[1], 1);
				execvp(path, argv);








|








>
|







174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
				if (posix_spawnattr_setflags(&attr,
				    POSIX_SPAWN_CLOEXEC_DEFAULT) != 0)
					@throw [OFInitializationFailedException
					    exceptionWithClass: self.class];
# endif

				if (posix_spawnp(&_pid, path, &actions, &attr,
				    argv, (env != NULL ? env : environ)) != 0)
					@throw [OFInitializationFailedException
					    exceptionWithClass: self.class];
			} @finally {
				posix_spawn_file_actions_destroy(&actions);
				posix_spawnattr_destroy(&attr);
			}
#else
			if ((_pid = vfork()) == 0) {
				if (env != NULL)
					environ = env;

				close(_readPipe[0]);
				close(_writePipe[1]);
				dup2(_writePipe[0], 0);
				dup2(_readPipe[1], 1);
				execvp(path, argv);