Check-in [413d9011a9]
Overview
Comment:Removed unneeded casts
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:413d9011a9dfd629585ac93aed10f6790d0cbfca
User & Date: rkeene on 2012-09-15 06:53:41
Other Links: manifest | tags
Context
2012-09-17
13:23
Updated to use uid/gid instead of usernames check-in: a48ac76ac7 user: rkeene tags: trunk
2012-09-15
06:53
Removed unneeded casts check-in: 413d9011a9 user: rkeene tags: trunk
06:48
Updated to check return value of chdir() check-in: 99eb340549 user: rkeene tags: trunk
Changes

Modified initrd/admin-tclkit/kitcreator-modules/system/system.c from [7d48c39a12] to [2a84d834a9].

  1951   1951   		Tcl_SetObjResult(interp, Tcl_NewStringObj("pipe failed", -1));
  1952   1952   
  1953   1953   		return(TCL_ERROR);
  1954   1954   	}
  1955   1955   
  1956   1956   	/* 3. Fork into a new process */
  1957   1957   	child = fork();
  1958         -	if (child == ((pid_t) -1)) {
         1958  +	if (child == -1) {
  1959   1959   		Tcl_SetObjResult(interp, Tcl_NewStringObj("fork failed", -1));
  1960   1960   
  1961   1961   		return(TCL_ERROR);
  1962   1962   	}
  1963   1963   
  1964   1964   	if (child != 0) {
  1965   1965   		/* 4.parent. Get PGID from child */
................................................................................
  1974   1974   		FD_ZERO(&read_fdset);
  1975   1975   		FD_SET(fd, &read_fdset);
  1976   1976   
  1977   1977   		select_ret = select(fd + 1, &read_fdset, NULL, NULL, &select_timeout);
  1978   1978   		if (select_ret == 0) {
  1979   1979   			/* On timeout, terminate starting process */
  1980   1980   			child_pgid = getpgid(child);
  1981         -			if (child_pgid != ((pid_t) -1)) {
         1981  +			if (child_pgid != -1) {
  1982   1982   				kill(-child_pgid, SIGKILL);
  1983   1983   			}
  1984   1984   
  1985   1985   			Tcl_SetObjResult(interp, Tcl_NewStringObj("timeout", -1));
  1986   1986   
  1987   1987   			return(TCL_ERROR);
  1988   1988   		}
................................................................................
  1998   1998   		if (read_ret != sizeof(child_pgid)) {
  1999   1999   			Tcl_SetObjResult(interp, Tcl_NewStringObj("failed to communicate with started service", -1));
  2000   2000   
  2001   2001   			return(TCL_ERROR);
  2002   2002   		}
  2003   2003   
  2004   2004   		/* 4.parent.e. If the PGID given is actually an error, return error */
  2005         -		if (child_pgid == ((pid_t) -1)) {
         2005  +		if (child_pgid == -1) {
  2006   2006   			Tcl_SetObjResult(interp, Tcl_NewStringObj("service failed to start", -1));
  2007   2007   
  2008   2008   			return(TCL_ERROR);
  2009   2009   		}
  2010   2010   
  2011   2011   		/* 4.parent.f. Return PGID to Tcl */
  2012   2012   		Tcl_SetObjResult(interp, Tcl_NewWideIntObj((Tcl_WideInt) child_pgid));
................................................................................
  2016   2016   
  2017   2017   	/* 4.child.a. Close read end of pipe -- we only write to it */
  2018   2018   	close(fds[0]);
  2019   2019   	fd = fds[1];
  2020   2020   
  2021   2021   	/* 5. Create a new session */
  2022   2022   	setsid_ret = setsid();
  2023         -	if (setsid_ret == ((pid_t) -1)) {
         2023  +	if (setsid_ret == -1) {
  2024   2024   		write(fd, &child_pgid, sizeof(child_pgid));
  2025   2025   
  2026   2026   		_exit(0);
  2027   2027   	}
  2028   2028   
  2029   2029   	/* 6. Setup environment */
  2030   2030   	/* 6.a. Set umask */
................................................................................
  2076   2076   	/* XXX: TODO */
  2077   2077   
  2078   2078   	/* 6.g.ii. User */
  2079   2079   	/* XXX: TODO */
  2080   2080   
  2081   2081   	/* 7. Create a new process to actually spawn the process */
  2082   2082   	child = fork();
  2083         -	if (child == ((pid_t) -1)) {
         2083  +	if (child == -1) {
  2084   2084   		write(fd, &child_pgid, sizeof(child_pgid));
  2085   2085   
  2086   2086   		_exit(0);
  2087   2087   	}
  2088   2088   
  2089   2089   	if (child != 0) {
  2090   2090   		/* 7.parent.a. Wait for child process to terminate and collect status */
  2091   2091   		waitpid_ret = waitpid(child, &status, 0);
  2092         -		if (waitpid_ret == ((pid_t) -1)) {
         2092  +		if (waitpid_ret == -1) {
  2093   2093   			status = -1;
  2094   2094   		}
  2095   2095   
  2096   2096   		/* 7.parent.b. Set PGID (if successful, -1 otherwise) to pass back to TSMF */
  2097   2097   		if (status == 0) {
  2098   2098   			child_pgid = getpgid(getpid());
  2099   2099   		}