How to send ctrl-C over the socket connection

How to send ctrl-C over the socket connection

Post by Gane » Sat, 22 Jun 1996 04:00:00



Hi All,
                I am working on a TALK implementation and everything
seems to be working perfectly except for the termination part.  
I want to how i can send Ctrl-C to the client on the other
machine so that i can terminate his process as well as mine.  
Please suggest me a way to send the signals
from one machine to the other over the socket connection.  

Thanks in advance
Ganesh
--
+------------------------------------------------------------------+
                    Ganesh Avalur Phani                  
+------------------------------------------------------------------+



+------------------------------------------------------------------+

 
 
 

How to send ctrl-C over the socket connection

Post by Jari Kok » Tue, 25 Jun 1996 04:00:00




>Please suggest me a way to send the signals
>from one machine to the other over the socket connection.  

Write a handler for SIGINT, and install it with signal(). When the
handler is called, set an extern flag variable, examine this flag in a
suitable place and then write ASCII 3 into the socket and exit. The
other end must check for received ctrl-c in its data, it won't get a
SIGINT.

If you just close the socket, the other end will get SIGPIPE when it
tries to write to it.

Jari Kokko

 
 
 

How to send ctrl-C over the socket connection

Post by Patrick Horg » Wed, 26 Jun 1996 04:00:00





> >Please suggest me a way to send the signals
> >from one machine to the other over the socket connection.  

> Write a handler for SIGINT, and install it with signal(). When the
> handler is called, set an extern flag variable, examine this flag in a
> suitable place and then write ASCII 3 into the socket and exit. The
> other end must check for received ctrl-c in its data, it won't get a
> SIGINT.

You might want to use the concept of tcp urgent data as well, it can get the
"signal" over to the other side in closer to real time.

Here's the routine I used to do it in a telnetd.  It only sends one byte as
urgent data since there's a discrepency between the spec and some implementations
as to whether the tcp urgent pointer points at the urgent data or just past it.
This work around made that a bit moot.

inline int telnet_state::write_oob(int fd,unsigned char *outbuf,size_t numchars)
{
    int retval,n=0;

    if (numchars > 1) {
        // send URGENT all by itself
        n+= send(fd,(const char*) outbuf, numchars-1, 0);
    }
    if(numchars > 0){
        retval= send(fd,(const char*)( outbuf+n-1), 1, MSG_OOB); /*URGENT data*/
        if(retval>0){
            n+=retval;
        }
    }
    return n;

Quote:}

--


   Opinions mine, not my employer's except by most bizarre coincidence.

 
 
 

How to send ctrl-C over the socket connection

Post by Vladimir Loba » Wed, 26 Jun 1996 04:00:00



> Hi All,
>                 I am working on a TALK implementation and everything
> seems to be working perfectly except for the termination part.
> I want to how i can send Ctrl-C to the client on the other
> machine so that i can terminate his process as well as mine.
> Please suggest me a way to send the signals
> from one machine to the other over the socket connection.

> Thanks in advance
> Ganesh
> --
> +------------------------------------------------------------------+
>                     Ganesh Avalur Phani
> +------------------------------------------------------------------+



> +------------------------------------------------------------------+

  Ok, the best way is to send out-of-band data (that's exactly what
telnet does when You press Ctrl-C). Do man select and look for
exceptions. When You receive such data - close sockets in both clients
and exit.

--
                                 .--------------------------------------.
.-------------------------------/      "Computium ergo foodium"       |
|  Vladimir Lobak at VDO Corp.  | I'm programming therefore i'm hungry. |

`-----------------------------------------------------------------------'

 
 
 

How to send ctrl-C over the socket connection

Post by Phil Edwar » Sat, 29 Jun 1996 04:00:00




+
+ Hi All,
+               I am working on a TALK implementation and everything
+ seems to be working perfectly except for the termination part.  
+ I want to how i can send Ctrl-C to the client on the other
+ machine so that i can terminate his process as well as mine.  
[snip massive sig]

If you manage to get this working, please let me know.  There's a few
processes on your machine I'd like to send arbitary singals to...

Luck++;
Phil

--

                                    The gods do not protect fools.  Fools are
                                protected by more capable fools. -Larry Niven

 
 
 

1. how to send control-break(ctrl-c) signal to a background process?

Dear all,

I have sent a job to run  in background... However I now want to gracefully
terminate it. This software has a good property that if I press
control-break, or ctrl-c, it will enter into a graceful termination mode
that it can still give me some partial useful information... so I don't want
to use "kill -9" to kill it...

instead, since it is run in background, I hope I can sent it a control-break
or ctrl-c signal then it can output some partial useful information to the
log file and then gracefully shutdown...

Can anybody help me on how to do that?

Thanks a lot,

-walala

2. MicroEMACS for Linux/Alpha

3. Who sends SIGINT in response to Ctrl-C?

4. hp laserjet 6l+RH6.1

5. how to send control-break or ctrl-c signal to background process?

6. mail notification?

7. rlogin connection killed by ctrl-C

8. A couple of questions

9. Opening a socket connection while in a socket connection.

10. How to detect broken socket connection when sending message

11. Trapping CTRL-C and CTRL-Z

12. Help with Term (ctrl-Z, and ctrl-c don't work!)

13. How to detect a socket connection broken when sending a message on Solaris