There's a function `isinteractive` already in base, does it solves the same
problem?
--Tim
On Sunday, March 02, 2014 10:31:16 PM Roger Herikstad wrote:
> Hi list,
> While running some code in parallel on my Mavericks system using Julia
> Version 0.3.0-prerelease+1741, I needed to prevent importing Tk if the
> current user did not have a console session, as this would crash the worker
> processes. In case it might be of general interest, this was my solution:
>
> function hasgui()
> username = split(readall(`who am i`))[1]
> return hasgui(username)
> end
>
> function hasgui(username::String)
> s = readall(`who`)
> return ismatch(Regex("$username[ \t]* console"),s)
> end