tags:

views:

243

answers:

4

When I did the command above, X11 opened. I am perplexed. Did I run it? How can I be sure that I do not run any program when looking at things? I really hate the idea that reading a text file may execute a program. How is it programmable possible to make programs that executes when running a simple cat-command, or similar command?

+3  A: 

If you run

file /tmp/:0

you should see that this is not a normal 'text' file but a socket. Aliasing ls thus

ls -F

will help identify such files automatically in your shell.

Brian Agnew
+2  A: 

machine:0 is an X display (the first display on 'machine')
I have never seen /tmp/:0 but it might be that your machine is configured so that all unmatched machine names map onto localhost. You haven't executed anything, the X server will simply try and interpret any commands sent by cat as X instructions. It's like doing cat to an http address

Martin Beckett
Can you clarify 'sent by cat' ? I think you mean 'cat X > Y', but there's no redirection in the above
Brian Agnew
There would be if he had sent some!
Martin Beckett
Your observation is probably right. I rechecked the tmp and I could only find :0 one dir deeper. I changed the question accordingly. Thank you!
Masi
+2  A: 

The :0 thing is a socket refering to the X server. Programs use this socket to communicate with the X server (for example to draw a window). Reading from this socket somehow caused the server to activate. The X server must have been already running before you did this command.

Zifre
I had played with the X-server. So you are probably right that it was running.
Masi
+3  A: 

This sounds like OSX 10.5 behaviour.

launchd listens on a socket '/tmp/launch-xxxxxx/:0'. The DISPLAY variable is set to tell X applications to write to that socket. When an X application opens the socket, launchd automatically starts 'X11.app' to provide the application with a display.

cat'ing the socket opens it and triggers X11.app. I don't think there are any other instances of that behaviour configured by default.

scottc