-2

This question already has an answer here:

Is a temrinal emulator process a server?

If yes, what is its client(s)? How can I find out its client(s)? Thanks.

  1. netstat output contains lxterminal processes. Does that mean that a terminal emulator process is a server based on unix domain socket?

    $ sudo netstat -ap | grep -i lxterminal
    [sudo] password for t: 
    unix  2      [ ACC ]     STREAM     LISTENING     28665    1480/lxterminal      /run/user/1000/.lxterminal-socket-:0
    unix  3      [ ]         STREAM     CONNECTED     28663    1480/lxterminal      
    unix  3      [ ]         STREAM     CONNECTED     28661    1480/lxterminal      
    unix  3      [ ]         STREAM     CONNECTED     28666    1480/lxterminal
    
  2. A server is always (or usually?) a daemon, so it doesn't have a controlling terminal. lxterminal doesn't have one (?):

    $ ps aux | grep -i lxterminal
    t         1480  0.1  0.3 473204 28232 ?        Sl   Nov21  22:39 lxterminal
    

marked as duplicate by JdeBP, Stéphane Chazelas, JigglyNaga, Jeff Schaller, thrig Dec 5 '18 at 15:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • See answer to the other question. – dirkt Dec 5 '18 at 7:56
3

A X server is a server because it serves a display and input devices to applications.

Applications like lxterminal connect to that X server to request some service. For instance:

  • Please draw a Window of that shape and size
  • Please tell me what key the user presses and releases

They connect to the X server over a UNIX domain or ABSTRACT or TCP socket.

Similarly, the terminal emulator could be considered as a server for terminal applications.

With echo test > /dev/pts/12, the echo application can be seen as connecting to the terminal emulator (by way of a pseudo-terminal instead of a network socket, though here the connection is done by the shell redirection, not echo) and requesting a service: please display test and move the cursor down.

Now, some terminal emulators including gnome-terminal and lxterminal have that (annoying IMO) feature where on first invocation they start a daemon process that handles future requests to open new terminal window.

Later invocations of those connect to that server (using that /run/user/1000/.lxterminal-socket-:0 UNIX domain socket in your case) to request a new terminal window, presumably to save resources or so that some information can be shared between terminal windows.

When you do:

cd /tmp && lxterminal -e vim

While there's already a lxterminal running, that second invocation just tells the lxterminal server to run vim in a new window with the current directory changed to /tmp.

See xterm or rxvt for terminal emulators that work in a more conventional way.

You can actually do that same with:

printf '%s\0' /tmp lxterminal -e vim |
  socat -u - 'unix-connect:"/run/user/1000/.lxterminal-socket-:0"'

I find it annoying because that means only the first invocation inherits the environment (environment in the global sense, including umask, cwd, env vars...) of the caller, later invocations only get the cwd.

More on that in @JdeBP's fine answer at lxterminal in the netstat output

  • Thanks. In unix.stackexchange.com/q/492752/674, is /run/user/1000/.lxterminal-socket- type=STREAM the socket that lxterminal uses for ensuring only one process running lxterminal? – Tim Jan 6 at 15:38

Not the answer you're looking for? Browse other questions tagged or ask your own question.