clean up zero-byte logfile on immediate exit

Otherwise, a zero-byte log file stays behind after every call to `i3
--get-socketpath`. Also, replace "return" calls with more explicit "exit"
calls.

Before:

$ ls -ld /tmp/i3* | wc -l; \
  repeat 10 i3 --get-socketpath >/dev/null; \
  ls -ld /tmp/i3* | wc -l
1
11

Now:

$ ls -ld /tmp/i3* | wc -l; \
  repeat 10 i3 --get-socketpath >/dev/null; \
  ls -ld /tmp/i3* | wc -l
1
1

Signed-off-by: Julius Plenz <julius@plenz.com>
This commit is contained in:
Julius Plenz
2012-08-11 01:50:37 +02:00
committed by Michael Stapelberg
parent da924aae6f
commit 70ec3867fe
3 changed files with 37 additions and 2 deletions

View File

@ -343,10 +343,10 @@ int main(int argc, char *argv[]) {
char *socket_path = root_atom_contents("I3_SOCKET_PATH");
if (socket_path) {
printf("%s\n", socket_path);
return 0;
exit(EXIT_SUCCESS);
}
return 1;
exit(EXIT_FAILURE);
} else if (strcmp(long_options[option_index].name, "shmlog-size") == 0 ||
strcmp(long_options[option_index].name, "shmlog_size") == 0) {
shmlog_size = atoi(optarg);