Gotcha. That is indeed an important problem to solve.

Thanks for posting your solution. It would be nice to have one that is not 
Unix-specific. If you don't have an immediate solution in mind, would you mind 
filing an issue with Tk?

BTW, Gtk doesn't seem to have this problem, and is probably the future of 
Julia graphics anyway.

--Tim

On Monday, March 03, 2014 11:16:38 PM Roger Herikstad wrote:
> I tried that, but my scenario is that I'm logged into a machine via ssh. It
> would still be an interactive session, but there is no console on which to
> show any graphics.
> 
> Regards,
> Roger Herikstad
> 
> > On 3 Mar, 2014, at 20:20, Tim Holy <[email protected]> wrote:
> > 
> > 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

Reply via email to