Check-in [36f57cf79b]
Overview
Comment:Updated to check return value of waitpid()
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 36f57cf79b1c674601da2a41f672c5f618915cb5
User & Date: rkeene on 2012-09-15 06:44:19
Other Links: manifest | tags
Context
2012-09-15
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
2012-09-09
21:25
Corrected example in test.tcl check-in: 8d15889864 user: rkeene tags: trunk
Changes

Modified system.c from [1d6aabc455] to [7ecfb38f87].

1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
}

static int tclsystem_tsmf_start_svc(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	struct timeval select_timeout;
	Tcl_WideInt umask_val, timeout_val;
	Tcl_Obj *filename_obj, *env_obj, *logfile_obj, **env_entry_objv, *cwd_obj, *umask_obj, *user_obj, *group_obj;
	Tcl_Obj *sri_obj, *timeout_obj;
	pid_t child, child_pgid = -1;
	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;







|







1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
}

static int tclsystem_tsmf_start_svc(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
	struct timeval select_timeout;
	Tcl_WideInt umask_val, timeout_val;
	Tcl_Obj *filename_obj, *env_obj, *logfile_obj, **env_entry_objv, *cwd_obj, *umask_obj, *user_obj, *group_obj;
	Tcl_Obj *sri_obj, *timeout_obj;
	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;
2079
2080
2081
2082
2083
2084
2085
2086



2087
2088
2089
2090
2091
2092
2093
		write(fd, &child_pgid, sizeof(child_pgid));

		_exit(0);
	}

	if (child != 0) {
		/* 7.parent.a. Wait for child process to terminate and collect status */
		waitpid(child, &status, 0);




		/* 7.parent.b. Set PGID (if successful, -1 otherwise) to pass back to TSMF */
		if (status == 0) {
			child_pgid = getpgid(getpid());
		}
		write(fd, &child_pgid, sizeof(child_pgid));








|
>
>
>







2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
2096
		write(fd, &child_pgid, sizeof(child_pgid));

		_exit(0);
	}

	if (child != 0) {
		/* 7.parent.a. Wait for child process to terminate and collect status */
		waitpid_ret = waitpid(child, &status, 0);
		if (waitpid_ret == ((pid_t) -1)) {
			status = -1;
		}

		/* 7.parent.b. Set PGID (if successful, -1 otherwise) to pass back to TSMF */
		if (status == 0) {
			child_pgid = getpgid(getpid());
		}
		write(fd, &child_pgid, sizeof(child_pgid));