I'm calling system("bash ../tools/bashScript \"This is an argument!\" &"), then I'm calling close(socketFD) directly after system returns, of course I've read that system's argument appended with a & will fork the command, so system returns immediately and I've checked that!
Now the problem is that I don't want the socket to stay connected while the command is being executed, but the weirdest thing is that the work flow of the program continues and close is somewhat seen and overlooked and once the command finishes the close takes effect!
I tried to call close twice after each others to make sure to delete every copy of the socketFD if created, still the same problem, I honestly don't know why close is being called but doesn't take effect until the command (the bash script) finishes!
Please advise!