diff options
author | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-04-15 23:47:58 +0000 |
---|---|---|
committer | Ingo Schwarze <schwarze@cvs.openbsd.org> | 2014-04-15 23:47:58 +0000 |
commit | e5bdc77c6356c32021aed1c9bd4a8ff646f64905 (patch) | |
tree | e521e3c2253520708197ff6efdc6a805a2b264a9 /usr.bin | |
parent | 747fcc7c1f8126cf31c39aefb7f83b181c2ca2c2 (diff) |
At the end of mansearch(), fchdir() back to where we started from;
this is cleaner and helps to not scatter gmon.out files all over
the place when profiling.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/mandoc/mansearch.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/usr.bin/mandoc/mansearch.c b/usr.bin/mandoc/mansearch.c index 930de9b6344..a419542524f 100644 --- a/usr.bin/mandoc/mansearch.c +++ b/usr.bin/mandoc/mansearch.c @@ -1,4 +1,4 @@ -/* $Id: mansearch.c,v 1.19 2014/04/11 15:45:39 schwarze Exp $ */ +/* $Id: mansearch.c,v 1.20 2014/04/15 23:47:57 schwarze Exp $ */ /* * Copyright (c) 2012 Kristaps Dzonsons <kristaps@bsd.lv> * Copyright (c) 2013, 2014 Ingo Schwarze <schwarze@openbsd.org> @@ -202,7 +202,7 @@ mansearch(const struct mansearch *search, */ if (NULL == getcwd(buf, PATH_MAX)) { - perror(NULL); + perror("getcwd"); goto out; } else if (-1 == (fd = open(buf, O_RDONLY, 0))) { perror(buf); @@ -339,9 +339,12 @@ mansearch(const struct mansearch *search, } rc = 1; out: - exprfree(e); - if (-1 != fd) + if (-1 != fd) { + if (-1 == fchdir(fd)) + perror(buf); close(fd); + } + exprfree(e); free(sql); *sz = cur; return(rc); |