MCPcopy Index your code
hub / github.com/git/git / start_async

Function start_async

run-command.c:1163–1276  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1161}
1162
1163int start_async(struct async *async)
1164{
1165 int need_in, need_out;
1166 int fdin[2], fdout[2];
1167 int proc_in, proc_out;
1168
1169 need_in = async->in < 0;
1170 if (need_in) {
1171 if (pipe(fdin) < 0) {
1172 if (async->out > 0)
1173 close(async->out);
1174 return error_errno("cannot create pipe");
1175 }
1176 async->in = fdin[1];
1177 }
1178
1179 need_out = async->out < 0;
1180 if (need_out) {
1181 if (pipe(fdout) < 0) {
1182 if (need_in)
1183 close_pair(fdin);
1184 else if (async->in)
1185 close(async->in);
1186 return error_errno("cannot create pipe");
1187 }
1188 async->out = fdout[0];
1189 }
1190
1191 if (need_in)
1192 proc_in = fdin[0];
1193 else if (async->in)
1194 proc_in = async->in;
1195 else
1196 proc_in = -1;
1197
1198 if (need_out)
1199 proc_out = fdout[1];
1200 else if (async->out)
1201 proc_out = async->out;
1202 else
1203 proc_out = -1;
1204
1205#ifdef NO_PTHREADS
1206 /* Flush stdio before fork() to avoid cloning buffers */
1207 fflush(NULL);
1208
1209 async->pid = fork();
1210 if (async->pid < 0) {
1211 error_errno("fork (async) failed");
1212 goto error;
1213 }
1214 if (!async->pid) {
1215 if (need_in)
1216 close(fdin[1]);
1217 if (need_out)
1218 close(fdout[0]);
1219 git_atexit_clear();
1220 process_is_async = 1;

Callers 7

get_packFunction · 0.85
send_packFunction · 0.85
apply_single_file_filterFunction · 0.85
prepare_sideband_asyncFunction · 0.85
run_proc_receive_hookFunction · 0.85
execute_commandsFunction · 0.85
unpack_with_sidebandFunction · 0.85

Calls 13

pipeFunction · 0.85
error_errnoFunction · 0.85
close_pairFunction · 0.85
forkFunction · 0.85
git_atexit_clearFunction · 0.85
mark_child_for_cleanupFunction · 0.85
pthread_selfFunction · 0.85
pthread_key_createFunction · 0.85
set_die_routineFunction · 0.85
set_cloexecFunction · 0.85
pthread_createFunction · 0.85

Tested by

no test coverage detected