aboutsummaryrefslogtreecommitdiff
path: root/unpack/fill_files.c
diff options
context:
space:
mode:
Diffstat (limited to 'unpack/fill_files.c')
-rw-r--r--unpack/fill_files.c62
1 files changed, 7 insertions, 55 deletions
diff --git a/unpack/fill_files.c b/unpack/fill_files.c
index c0fc26c..df6ca7e 100644
--- a/unpack/fill_files.c
+++ b/unpack/fill_files.c
@@ -38,65 +38,17 @@ static int fill_files(data_reader_t *data, file_info_t *list, int flags)
return 0;
}
-int fill_unpacked_files(fstree_t *fs, data_reader_t *data, int flags,
- unsigned int num_jobs)
+int fill_unpacked_files(fstree_t *fs, data_reader_t *data, int flags)
{
- file_info_t **sublists, *it;
- int exitstatus, status = 0;
- unsigned int i;
- pid_t pid;
+ file_info_t *list, *it;
+ int status = 0;
- if (num_jobs < 1)
- num_jobs = 1;
+ list = optimize_unpack_order(fs);
- sublists = alloca(sizeof(sublists[0]) * num_jobs);
- optimize_unpack_order(fs, num_jobs, sublists);
+ status = fill_files(data, list, flags);
- if (num_jobs < 2) {
- status = fill_files(data, sublists[0], flags);
- goto out;
- }
-
- for (i = 0; i < num_jobs; ++i) {
- pid = fork();
-
- if (pid == 0) {
- /* Kill the child when the parent process dies */
- prctl(PR_SET_PDEATHSIG, SIGKILL);
-
- if (fill_files(data, sublists[i], flags))
- exit(EXIT_FAILURE);
- exit(EXIT_SUCCESS);
- }
-
- if (pid < 0) {
- perror("fork");
- status = -1;
- break;
- }
- }
-
- for (;;) {
- errno = 0;
- pid = waitpid(-1, &exitstatus, 0);
-
- if (pid < 0) {
- if (errno == EINTR)
- continue;
- if (errno == ECHILD)
- break;
- }
-
- if (!WIFEXITED(exitstatus) ||
- WEXITSTATUS(exitstatus) != EXIT_SUCCESS) {
- status = -1;
- }
- }
-out:
- for (i = 0; i < num_jobs; ++i) {
- for (it = sublists[i]; it != NULL; it = it->next)
- free(it->input_file);
- }
+ for (it = list; it != NULL; it = it->next)
+ free(it->input_file);
return status;
}