Skip to content

Commit

Permalink
free memory in file_list before forking
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaboud committed Apr 22, 2021
1 parent 220f3dc commit 6d1819f
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/impl/exec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,11 @@ void SyncProcess::sync_batch(){
argv.push_back(NULL);

pid_ = fork(); // create child process
int error;
switch(pid_){
case -1:
Logging::log.error("Forking failed");
error = errno;
Logging::log.error(std::string("Forking failed: ") + strerror(error));
l::exit(EXIT_FAILURE);
case 0: // child process
{
Expand Down Expand Up @@ -377,4 +379,5 @@ void Syncer::distribute_files(std::vector<File> &queue, std::list<SyncProcess> &
// circularly iterate
if(proc_itr == distribute_pool.end()) proc_itr = distribute_pool.begin();
}
queue.shrink_to_fit(); // free up memory ahead of forks
}

0 comments on commit 6d1819f

Please sign in to comment.