@@ -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 ;
@@ -8824,6 +8831,46 @@ TestLutilCmd(
8824
8831
return ret ;
8825
8832
}
8826
8833
8834
+ #ifdef _WIN32
8835
+ /*
8836
+ *----------------------------------------------------------------------
8837
+ *
8838
+ * TestHandleCountCmd --
8839
+ *
8840
+ * This procedure implements the "testhandlecount" command. It returns
8841
+ * the number of open handles in the process.
8842
+ *
8843
+ * Results:
8844
+ * A standard Tcl result.
8845
+ *
8846
+ * Side effects:
8847
+ * None.
8848
+ *
8849
+ *----------------------------------------------------------------------
8850
+ */
8851
+
8852
+ static int
8853
+ TestHandleCountCmd (
8854
+ TCL_UNUSED (void * ),
8855
+ Tcl_Interp * interp , /* Current interpreter. */
8856
+ int objc , /* Number of arguments. */
8857
+ Tcl_Obj * const objv []) /* Arguments. */
8858
+ {
8859
+ DWORD count ;
8860
+ if (objc != 1 ) {
8861
+ Tcl_WrongNumArgs (interp , 1 , objv , "" );
8862
+ return TCL_ERROR ;
8863
+ }
8864
+ if (GetProcessHandleCount (GetCurrentProcess (), & count )) {
8865
+ Tcl_SetObjResult (interp , Tcl_NewWideIntObj (count ));
8866
+ return TCL_OK ;
8867
+ }
8868
+ Tcl_SetObjResult (interp , Tcl_NewStringObj (
8869
+ "GetProcessHandleCount failed" , -1 ));
8870
+ return TCL_ERROR ;
8871
+ }
8872
+ #endif /* _WIN32 */
8873
+
8827
8874
/*
8828
8875
* Local Variables:
8829
8876
* mode: c
0 commit comments