Section 319(3) in The Code of Criminal Procedure, 1973
(3)Any person attending the Court, although not under arrest or upon a summons, may be detained by such Court for the purpose of the inquiry into, or trial of, the offence which he appears to have committed.