problem with syslog(), C function :(

problem with syslog(), C function :(

Post by Simone Chemel » Wed, 12 Feb 1997 04:00:00



I wrote this simple daemon in order to know when i use the modem. It should
work whith every porogram such as ppp, hylafax, minicom and so on.
But with pp i have some problems. When the connection stops non syslog()
call is done and so nothing is wrote in the /var/log/messages file.
The start line instead is well recorded.

Any idea?

Simone

/******************************************************************

 Modemd: trace status line of /dev/ttyS[x] and logs through syslog calls


******************************************************************/

#include <stdlib.h>
#include <stdio.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <string.h>
#include <unistd.h>
#include <syslog.h>
#define LINE "/dev/ttyS1"
#define Facility  LOG_DAEMON
#define Level     LOG_INFO

void main(int argc, char *argv[])
{

        int Priority = (Facility && Level), fh, w = 0;
        unsigned int status;
        unsigned int ioret;
        char *strip_name;

        strip_name = strrchr(argv[0], '/');
        if(strip_name == NULL) strip_name=argv[0];
        else strip_name++;
        openlog(strip_name,LOG_NDELAY,Facility);
        syslog(Priority, "starting.");
        switch(fork()) {
           case  0: setsid();
                    break;
           case -1: syslog(Priority, "can't fork.");
                    closelog();
                    exit(2);
           default: exit(0);
        }

        fh = open(LINE,O_RDONLY);
        if(fh == -1) {
                syslog(Priority, "can't open %s.", LINE);
                closelog();
                exit(3);
        }

        for (;;)  {

                status = ioctl(fh, TIOCMGET, &ioret);
                if(status) {
                   close(fh);
                   fh = open(LINE,O_RDONLY);
                   if(fh == -1) {
                       syslog(Priority, "can't open %s.", LINE);
                       closelog();
                       exit(2);
                   }
                }

           if (ioret & TIOCM_CAR) {
               if(!w) syslog(Priority, "Carrier is HIGH (connection starts).");
                           w = 1;
                }
                else
                {
           if(w) syslog(Priority, "Carrier is LOW  (connection stops ).");
                           w = 0;
                }
                fflush(stdout);
                sleep(1);
        }

Quote:}

--
                  Simone Chemelli

                                http://www.dei.unipd.it/~genius
 
 
 

1. Talk refused to talk:(:(:(:(

Hello there people:)...
  I had linux kernel 1.2.8 installed in my system. I have a SLIP/PPP
connection using either dip (for SLIP) or pppd/chat (for PPP).
  Now, Most of my network stuff are working fine without any problem at all
except talk. Talk works fine for local chatting. No problem at all. The
problem is when ever I call out to other machine (using the SLIP/PPP line),
nothing has ever happen. It got as far as Checking invitation stuff. Never
more.
  Just out of curiosity I ran netstate to check the udp connection whenever
I have talk running. Running locally (talk that is) I got output as follow:

Active Internet connections
Proto Recv-Q Send-Q Local Address          Foreign Address        (State)
User
udp        0      0 lucifer.newpaltz.:1328 *:*                    

Which I presumed opened by talk (only one here because the other side hadn't
responded to the call yet).  I also get the same thing whenever I call
someone outside my system to talk. Of course, it never got to the other
system (I was waiting on the other system using telnet for the talk request,
never got there. And I had made sure that mesg was y).

Now when I call *IN* from other system (telnet to another system and run
talk over there to my system), I have (on my system) output as follow:

Active Internet connections
Proto Recv-Q Send-Q Local Address          Foreign Address        (State)
User

And also from netstat -a, I could find talk/ntalk were still listening.
Seems to me the call from outside didn't get through.

Now, since I haven't done anything to configure talk specifically, is there
anything I have to do to make this connection possible. Since I can't talk
to outside nor can I receive talk request from other hosts, I'm under the
assumption that my talk program somehow is not configured properly.

Any configuration file I have to check?
man, faq, howto, etc to refer to this kind of error?
May be replace my talk/ntalk/talkd/ntalkd with something else and where to
find it/them?
Does it depend on something in the kernel that I have to enable during the
compile time?
Wrong version altogether with the kernel?
Is it possible that talk needs long time to make the connection? (None of my
other stuff that I know of behave like this).
May be my inetd is broken?
If so, how do I check for it?
And where to find the latest version of it?

And while I'm at it, what's the latest version of talk?
Where to find it?
Is there a better chatting program that's backward compatible with talk?
Meaning that the program has more features than talk but at the same time
can be used to communicate with other regular talk program whenever the
program is not available on the other host.

--
Send comment and reply to:



2. Legal technicality puts Linux programmers at risk

3. my trashed hard drive. :( :( :(

4. Please confirm for me...

5. Tuning syslog/Syslog reporting/Syslog enhancement/replacements

6. Termcap problems on dial-in....

7. creating different syslog file /var/log/syslog.0 /var/log/syslog.1...

8. upgrading to windows 95

9. syslog output to screen :(

10. function, function...who's got the function?

11. syslog functions ported to Windows NT

12. syslog functioning weird?

13. inetd dies :(:(