Find the answer to your Linux question:
Results 1 to 6 of 6
suppose the client and the server are communicating and i kill the client using "kill -9 pid " command how does the server comes to know that the client is ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2011
    Posts
    29

    indication to server on killing the client


    suppose the client and the server are communicating and i kill the client using "kill -9 pid " command how does the server comes to know that the client is killed.
    I want to know how does the kill command works.
    Is it that the kill command uses a signal which is passed to the server and server also quits??
    If a signal then which signal???
    Please help me out

  2. #2
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    To learn that, start with man kill.

    kill -9 sends the pid of a given process the SIGKILL signal. You can list the possible processes that kill can send with:

    Code:
    kill -l
    The server will know nothing of the killing of the pid on the client, per se. If you are talking about a specific process or daemon running on a server, to which an application is connecting on a client, then, yes, that server might very well notice that the client has stopped responding (due in part to the hand-shaking process of TCP), but it by no means would cause the server process to abort (unless it was specifically designed to do that).

  3. #3
    Just Joined!
    Join Date
    Dec 2011
    Posts
    29
    Quote Originally Posted by atreyu View Post
    To learn that, start with man kill.

    kill -9 sends the pid of a given process the SIGKILL signal. You can list the possible processes that kill can send with:

    Code:
    kill -l
    The server will know nothing of the killing of the pid on the client, per se. If you are talking about a specific process or daemon running on a server, to which an application is connecting on a client, then, yes, that server might very well notice that the client has stopped responding (due in part to the hand-shaking process of TCP), but it by no means would cause the server process to abort (unless it was specifically designed to do that).

    Actually I am using a client server program using UNIX sockets
    So, whenever i kill the client the server is not killed but it goes again in the listening mode (bcoz it is a server for multiple client).
    So, I want to know what makes the server to release the client connection ie close(fd) .and listen for a new client whenever the client is checkpoited. Kill command is connected to only the pid which is passed to it i.e. the client then how does the server aborts the connection with the killed client and goes in to listening mode.
    I mean there must be some code in the send or recv socket functions which must be responding to the server that client is killed.
    And also when we are killing the client that time all the fds assign to it must be released . How does the server knows that the socket descriptor is no more and the client is killed

    Please help me out

  4. #4
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    So you are writing these socket programs yourself, then? What I might do is, you can have your client-side prog trap a kill signal (any sig you want, except SIGKILL), and when it does trap a signal, send a disconnect to the server, then quit. That way, the client will be "killed" and the server's connection will have been severed and so restart.

    At a lower level, are you using a programming API to open/close/create these socket connections? I would assume that what you want to do is documented there somewhere.

  5. #5
    Just Joined!
    Join Date
    Dec 2011
    Posts
    29
    Quote Originally Posted by atreyu View Post
    So you are writing these socket programs yourself, then? What I might do is, you can have your client-side prog trap a kill signal (any sig you want, except SIGKILL), and when it does trap a signal, send a disconnect to the server, then quit. That way, the client will be "killed" and the server's connection will have been severed and so restart.

    At a lower level, are you using a programming API to open/close/create these socket connections? I would assume that what you want to do is documented there somewhere.
    As per u said I had trapped the SIGPIPE signal on the server side.
    But after receiving this signal it goes to my written signal handler(where i have written " this is SIGPIPE signal") and the server again goes into listening mode. The server connection is not reserved as u said.
    Also SIGPIPE signal is invoked only when I kill the client when the server was writing to the pipe
    But when the server is receiving that time no signal is invoked when i kill the client and the server agian goes into listening mode.
    Can u please tell me what changes i need to do so that when i kill the client the pipe is not broken and the same connection can be used when the client restarts.
    Actually i am working on checkpoint/restart mechanism (BLCR) where we are trying to restore the client connection.
    So please tell me how can i avoid breaking of the pipe when the client is killed.

  6. #6
    Trusted Penguin
    Join Date
    May 2011
    Posts
    4,353
    I am thinking your problem is more one of a socket programming nature, versus how to make Linux utilities manage sockets. In other words, there must be a way to do what you want natively using a proper socket API. Perhaps you could find a good book on socket programming, or google for a good tutorial. At any rate, I couldn't help you any further without doing the same myself anyway.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •