Check-in [ecc5931c14]
Overview
Comment:Updated to check return value of chdir()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:ecc5931c145c483100006cbe8f591190d7e0b2d7
User & Date: rkeene on 2012-09-15 06:48:04
Other Links: manifest | tags
Context
2012-09-15
06:53
Removed unneeded casts check-in: e91caa4ecf user: rkeene tags: trunk
06:48
Updated to check return value of chdir() check-in: ecc5931c14 user: rkeene tags: trunk
06:44
Updated to check return value of waitpid() check-in: 36f57cf79b user: rkeene tags: trunk
Changes

Modified system.c from [7ecfb38f87] to [7d48c39a12].

1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
....
2027
2028
2029
2030
2031
2032
2033
2034





2035
2036
2037
2038
2039
2040
2041
	pid_t child, child_pgid = -1, waitpid_ret;
	ssize_t read_ret;
	time_t currtime;
	char *argv[3], *envv[512];
	char *logfile, *filename, *cwd, *user, *group;
	char logmsg[2048];
	fd_set read_fdset;
	int pipe_ret, setsid_ret, execve_ret, tcl_ret, select_ret;
	int null_fd, log_fd, tmp_fd, max_fd;
	int env_entry_objc;
	int fds[2], fd;
	int status;
	int idx;

	/* 1. Parse arguments */
................................................................................
	}

	/* 6. Setup environment */
	/* 6.a. Set umask */
	umask(umask_val);

	/* 6.b. Set working directory */
	chdir(cwd);






	/* 6.c. Open log file for stderr and stdout */
	log_fd = open(logfile, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);

	/* 6.d. Open "/dev/null" for stdin */
	null_fd = open("/dev/null", O_RDONLY);
	if (null_fd < 0 || log_fd <0) {







|







 







|
>
>
>
>
>







1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
....
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
	pid_t child, child_pgid = -1, waitpid_ret;
	ssize_t read_ret;
	time_t currtime;
	char *argv[3], *envv[512];
	char *logfile, *filename, *cwd, *user, *group;
	char logmsg[2048];
	fd_set read_fdset;
	int pipe_ret, setsid_ret, execve_ret, tcl_ret, select_ret, chdir_ret;
	int null_fd, log_fd, tmp_fd, max_fd;
	int env_entry_objc;
	int fds[2], fd;
	int status;
	int idx;

	/* 1. Parse arguments */
................................................................................
	}

	/* 6. Setup environment */
	/* 6.a. Set umask */
	umask(umask_val);

	/* 6.b. Set working directory */
	chdir_ret = chdir(cwd);
	if (chdir_ret != 0) {
		write(fd, &child_pgid, sizeof(child_pgid));

		_exit(0);
	}

	/* 6.c. Open log file for stderr and stdout */
	log_fd = open(logfile, O_WRONLY | O_CREAT | O_APPEND, S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);

	/* 6.d. Open "/dev/null" for stdin */
	null_fd = open("/dev/null", O_RDONLY);
	if (null_fd < 0 || log_fd <0) {