ObjFW  Check-in [c9125d25d4]

Overview
Comment:OFSubprocess: Correctly handle nil environment
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | 1.0
Files: files | file ages | folders
SHA3-256: c9125d25d44ed8b318bf68f0a77df92ed793965cddcfc7af5e5ce22e1c89584f
User & Date: js on 2024-01-21 09:39:30
Other Links: branch diff | manifest | tags
Context
2024-01-21
09:56
OFSubprocess: Fix dealloc after -[closeForWriting] check-in: 9882a09715 user: js tags: 1.0
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
15:18
+[OFSystemInfo networkInterfaces]: Avoid IfIndex check-in: 0a6eddb5bc user: js tags: 1.0
Changes

Modified src/platform/POSIX/OFSubprocess.m from [bb0f04408f] to [99bd20546d].

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);