Skip to content

Commit

Permalink
remove file if mkstemp succeeded
Browse files Browse the repository at this point in the history
  • Loading branch information
p-alik committed Nov 21, 2018
1 parent aec4852 commit 6ca3f04
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions libtest/signal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -216,11 +216,11 @@ SignalThread::SignalThread() :
sigaddset(&set, SIGUSR2);

strcpy(lock_name, "/XXXXXXXX");
if (mkstemp(lock_name) == -1)
// random lock_name required
if (mkstemp(lock_name) != -1)
{
// it doesn't matter
// mkstemp should get random lock_name
// Error << strerror(errno) << " mkstemp failed.";
// remove unnecessary file
remove(lock_name);
}

sigemptyset(&original_set);
Expand Down
8 changes: 4 additions & 4 deletions util/signal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,11 @@ SignalThread::SignalThread(bool exit_on_signal_arg) :
sigaddset(&set, SIGUSR2);

strcpy(lock_name, "/XXXXXXXXX");
if (mkstemp(lock_name) == -1)
// random lock_name required
if (mkstemp(lock_name) != -1)
{
// it doesn't matter
// mkstemp should get random lock_name
// std::cerr << strerror(errno) << " mkstemp failed.";
// remove unnecessary file
remove(lock_name);
}
}

Expand Down

0 comments on commit 6ca3f04

Please sign in to comment.