check chdir(2) & freopen(3) errors
This commit is contained in:
parent
ddf9b11261
commit
a23ce91358
1 changed files with 6 additions and 3 deletions
9
stt.c
9
stt.c
|
|
@ -72,8 +72,9 @@ opentimesfile()
|
|||
//oldcwd = dirfd(opendir("."));
|
||||
|
||||
passwd = getpwuid(getuid());
|
||||
chdir(passwd->pw_dir);
|
||||
|
||||
if (chdir(passwd->pw_dir) == -1) {
|
||||
perror("chdir failed");
|
||||
}
|
||||
fp = fopen(timesfile, "a+");
|
||||
|
||||
if (fp == NULL) {
|
||||
|
|
@ -377,7 +378,9 @@ default:
|
|||
changed = 1;
|
||||
}
|
||||
if (changed) {
|
||||
freopen(timesfile, "w", fp);
|
||||
if (freopen(timesfile, "w", fp) == NULL) {
|
||||
perror("reopen failed");
|
||||
}
|
||||
writetimes(fp, timestree);
|
||||
}
|
||||
if (list) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue