Check-in [9839015dcd]
Overview
SHA1:9839015dcd3cd55f7ffff44342649f1ec1de6fb6
Date: 2014-12-23 08:05:45
User: rkeene
Comment:Added a simple "waitpid" implementation
Timelines: family | ancestors | descendants | both | trunk
Downloads: Tarball | ZIP archive
Other Links: files | file ages | folders | manifest
Tags And Properties
Context
2014-12-25
04:09
[5405269774] Added "reboot" command and stub for "eject" command (user: rkeene, tags: trunk)
2014-12-23
08:05
[9839015dcd] Added a simple "waitpid" implementation (user: rkeene, tags: trunk)
06:19
[2fe4c86606] Updated to include more logs for TSMF starter (user: rkeene, tags: trunk)
Changes

Modified tuapi.c from [3b213ed76e] to [a87ca8451c].

  2241   2241   			return(TCL_OK);
  2242   2242   	}
  2243   2243   
  2244   2244   	Tcl_SetObjResult(interp, Tcl_NewStringObj("invalid subcommand", -1));
  2245   2245   
  2246   2246   	return(TCL_ERROR);
  2247   2247   }
         2248  +
         2249  +static int tuapi_waitpid(ClientData cd, Tcl_Interp *interp, int objc, Tcl_Obj *CONST objv[]) {
         2250  +	pid_t child;
         2251  +	int status;
         2252  +
         2253  +	child = waitpid(-1, &status, WNOHANG);
         2254  +	if (child < 0) {
         2255  +		if (errno != ECHILD) {
         2256  +			Tcl_SetObjResult(interp, Tcl_NewStringObj(strerror(errno), -1));
         2257  +
         2258  +			return(TCL_ERROR);
         2259  +		} else {
         2260  +			child = 0;
         2261  +		}
         2262  +	}
         2263  +
         2264  +	if (child != 0) {
         2265  +		Tcl_SetObjResult(interp, Tcl_NewWideIntObj(child));
         2266  +	}
         2267  +
         2268  +	return(TCL_OK);
         2269  +}
  2248   2270   
  2249   2271   #ifndef DISABLE_UNIX_SOCKETS
  2250   2272   struct tuapi_socket_unix__chan_id {
  2251   2273   	int fd;
  2252   2274   	Tcl_Channel chan;
  2253   2275   };
  2254   2276   
................................................................................
  2991   3013   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::mknod", tuapi_mknod, NULL, NULL);
  2992   3014   
  2993   3015   	/* Process related commands */
  2994   3016   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::getuid", tuapi_getuid, NULL, NULL);
  2995   3017   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::chroot", tuapi_chroot, NULL, NULL);
  2996   3018   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::pivot_root", tuapi_pivot_root, NULL, NULL);
  2997   3019   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::kill", tuapi_kill, NULL, NULL);
         3020  +	Tcl_CreateObjCommand(interp, "::tuapi::syscall::waitpid", tuapi_waitpid, NULL, NULL);
  2998   3021   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::ps", tuapi_ps, NULL, NULL);
  2999   3022   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::execve", tuapi_execve, NULL, NULL);
  3000   3023   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::rlimit", tuapi_rlimit, NULL, NULL);
  3001   3024   
  3002   3025   	/* Network related commands */
  3003   3026   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::ifconfig", tuapi_ifconfig, NULL, NULL);
  3004   3027   	Tcl_CreateObjCommand(interp, "::tuapi::syscall::route", tuapi_route, NULL, NULL);