serial processes not dying with hangup (reliably)

serial processes not dying with hangup (reliably)

Post by Kelly Carmicha » Mon, 28 Aug 1995 04:00:00



I am having some difficulty getting linux to send a hangup signal to
processes running on a serial port when the modem drops carrier

it appears it gets stuck when there is some data pending to be
transmitted on the device.

any suggestions how to solve this problem?

 
 
 

serial processes not dying with hangup (reliably)

Post by Tony Nugen » Tue, 29 Aug 1995 04:00:00



>I am having some difficulty getting linux to send a hangup signal to
>processes running on a serial port when the modem drops carrier
>it appears it gets stuck when there is some data pending to be
>transmitted on the device.
>any suggestions how to solve this problem?

This is something that was recently posted to the linux-ppp email
list.  It might be useful and adapatable to your situation.

========8<-----------cut-here------------>8====================

Date: Thu, 24 Aug 95 08:02 BST



Precedence: bulk

Newsgroups: linux.dev.ppp
Path: roestock!fox

Subject: Re: PPPd won't die - argh....


Organization: home
Date: Wed, 23 Aug 1995 16:50:11 GMT

: For what it's worth, I have no problem killing the pppd, but after I do,
: the chat program refuses to dial my ISP again. For some reason (unknown
: to me) it reports getting a ^M back from the modem instead of an OK and
: the ppp-on script fails. To be honest, I had this problem with earlier
: pppd versions. I am running pppd (960727) and linux 1.2.13. The same
: modem, connect string, and ISP work fine with MS Windows and Netmanage
: Chameleon. (Tsk!) I have reported chat problem before, but never got a
: response.

: If anyone can help, please advise. It's really a royal PITA to have to
: shutdown -r every time I log off the Internet.

A few hints:
1. Use the hardware control lines, specifically: get the modem to
reset on loss of dtr.

2. Watch out for characters buffered in the driver. chat doesn't seem
to clear the device buffers.

3. I have had trouble in my dial script with the modem not dropping
the line on a retry (+++ not returning the modem to command mode).
In the end I wrote a small program to drop DTR and flush the buffers,
to include in the script. As it is so short, I'll include it here:

#include <termios.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>

/* Pulse DTR low on stdin device */
main()
{
  int arg = TIOCM_DTR;
  /* Clear any *remaining */
  if(tcflush(STDIN_FILENO, TCIOFLUSH) < 0)
  {
    perror("tcflush 1 failed");
    exit(2);
  }
  /* Now pulse DTR */
  if(ioctl(STDIN_FILENO, TIOCMBIC, &arg) < 0)
  {
    perror("TIOCMBIC ioctl failed");
    exit(2);
  }
  sleep(1);
  if(ioctl(STDIN_FILENO, TIOCMBIS, &arg) < 0)
  {
    perror("TIOCMBIS ioctl failed");
    exit(2);
  }
  sleep(1);
  /* Clear any *remaining */
  if(tcflush(STDIN_FILENO, TCIOFLUSH) < 0)
  {
    perror("tcflush 2 failed");
    exit(2);
  }
  exit(0);

Quote:}

This worked wonders.

Peter.

========8<-----------cut-here------------>8====================

Cheers
Tony
                                                             \\|//
                                                             (O-O)
  -------------------------------------------------------oOO--(_)--OOo-----
     Tony Nugent  Griffith University, Brisbane, Queensland, Australia

  -------------------------------------------------------------------------

 
 
 

1. child processes not dying with parent process??

Hello all,

I have an application program which spawns a few child processes. This
application program has to start from a shell script in background mode.
When I kill (kill -9 <pid> from a login shell) the parent process, the
child processes remain active, and have to be killed individually.
Doesn't the parent issue a SIGKILL of some sort to all its children??

At the moment, the parent process has a SA_NOCLDWAIT set so that when its
child process dies, they don't leave <defunc> processes lying around.
That is the only signal-related code I have in the code.

Any info is greatly appreciated...please e-mail as I don't read this
newsgroup.

Thanks in advance,


Level 1,
30, Kings Park Road,
West Perth, 6005,
Western Australia.

2. streaks with GD5434

3. Telnet dies but process does NOT, why not?

4. how shall it hang? or not...

5. PPP Inbound, not killing process after hangup

6. Does Linux support DLT-Drives ??????????

7. background process persist-or-die when its parent shell dies

8. NFS Install

9. Help: Keeping several processes in sync - one dies they all die

10. Son processes don't die when father die..

11. Reading serial port *reliably*

12. ProFTPd: child process not dying

13. processes not dying on tty