@@ -334,6 +334,9 @@ static Tcl_ObjCmdProc TestInterpResolverCmd;
334
334
static Tcl_ObjCmdProc TestcpuidCmd ;
335
335
#endif
336
336
static Tcl_ObjCmdProc TestApplyLambdaCmd ;
337
+ #ifdef _WIN32
338
+ static Tcl_ObjCmdProc TestHandleCountCmd ;
339
+ #endif
337
340
338
341
static const Tcl_Filesystem testReportingFilesystem = {
339
342
"reporting" ,
@@ -725,6 +728,10 @@ Tcltest_Init(
725
728
NULL , NULL );
726
729
Tcl_CreateObjCommand (interp , "testlutil" , TestLutilCmd ,
727
730
NULL , NULL );
731
+ #if defined(_WIN32 )
732
+ Tcl_CreateObjCommand (interp , "testhandlecount" , TestHandleCountCmd ,
733
+ NULL , NULL );
734
+ #endif
728
735
729
736
if (TclObjTest_Init (interp ) != TCL_OK ) {
730
737
return TCL_ERROR ;
@@ -8792,6 +8799,46 @@ TestLutilCmd(
8792
8799
return ret ;
8793
8800
}
8794
8801
8802
+ #ifdef _WIN32
8803
+ /*
8804
+ *----------------------------------------------------------------------
8805
+ *
8806
+ * TestHandleCountCmd --
8807
+ *
8808
+ * This procedure implements the "testhandlecount" command. It returns
8809
+ * the number of open handles in the process.
8810
+ *
8811
+ * Results:
8812
+ * A standard Tcl result.
8813
+ *
8814
+ * Side effects:
8815
+ * None.
8816
+ *
8817
+ *----------------------------------------------------------------------
8818
+ */
8819
+
8820
+ static int
8821
+ TestHandleCountCmd (
8822
+ TCL_UNUSED (void * ),
8823
+ Tcl_Interp * interp , /* Current interpreter. */
8824
+ int objc , /* Number of arguments. */
8825
+ Tcl_Obj * const objv []) /* Arguments. */
8826
+ {
8827
+ DWORD count ;
8828
+ if (objc != 1 ) {
8829
+ Tcl_WrongNumArgs (interp , 1 , objv , "" );
8830
+ return TCL_ERROR ;
8831
+ }
8832
+ if (GetProcessHandleCount (GetCurrentProcess (), & count )) {
8833
+ Tcl_SetObjResult (interp , Tcl_NewWideIntObj (count ));
8834
+ return TCL_OK ;
8835
+ }
8836
+ Tcl_SetObjResult (interp , Tcl_NewStringObj (
8837
+ "GetProcessHandleCount failed" , -1 ));
8838
+ return TCL_ERROR ;
8839
+ }
8840
+ #endif /* _WIN32 */
8841
+
8795
8842
/*
8796
8843
* Local Variables:
8797
8844
* mode: c
0 commit comments