Gilroy was born in Sydney, to working-class parents of Irish descent. Educated at the Marist Brothers' College in the Sydney suburb of Kogarah, he left school when 13 years old, to work as a messenger boy in what was then the Postmaster-General's Department. In 1914 his parents refused permission for him to enlist in the Australian Army, but he was allowed to volunteer for the transport service as a telegraphist. He left Australia in February 1915 and served in the Gallipoli campaign of World War I in 1915 as a naval wireless operator on the "Hessen" off Gallipoli and Imbros.