Skip to content

Commit

Permalink
Fix things
Browse files Browse the repository at this point in the history
  • Loading branch information
dchansen06 committed Dec 20, 2024
1 parent 1ba9809 commit f419fa9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/client_functions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,21 @@ int getInformation(string& path, string& dir, int argc, char* argv[])

int setupServer(string path, string directory)
{
int server = fork();
pid_t server = fork();

if (server == 0) {
pid_t sid = setsid();

if (sid < 0) {
cerr << "Failed to start server! Could not setsid\n";
exit(-1);
}

if (server == 0)
execl(path.c_str(), path.c_str(), directory.c_str(), nullptr);
} else if (server < 0) {
cerr << "Failed to start server! Could not fork\n";
exit(-1);
}

return server;
}
Expand Down

0 comments on commit f419fa9

Please # to comment.