[asterisk-dev] Shouldn't Asterisk call chdir("/") when becoming a daemon?

Chris Maciejewski chris at wima.co.uk
Wed Apr 22 16:33:44 CDT 2009


Hi,

Running in the asterisk source directory:

$ find . -name "*.c" -exec grep -Hn 'chdir(' {} \;

only produces:

./res/res_musiconhold.c:495:		if (strcasecmp(class->dir, "nodir") &&
chdir(class->dir) < 0) {
./res/res_musiconhold.c:496:			ast_log(LOG_WARNING, "chdir() failed:
%s\n", strerror(errno));
./res/res_musiconhold.c:917:	if (chdir(class->dir) < 0) {
./res/res_musiconhold.c:918:		ast_log(LOG_WARNING, "chdir() failed:
%s\n", strerror(errno));
./res/res_musiconhold.c:957:	if (chdir(path) < 0) {
./res/res_musiconhold.c:958:		ast_log(LOG_WARNING, "chdir() failed:
%s\n", strerror(errno));

so looks like asterisk is not calling chdir("/") anywhere, apart from
res/res_musiconhold.c .
AFAIK it is a recommended for all linux daemon processes to call
chdir("/") when forking.

Regards,
Chris



More information about the asterisk-dev mailing list