Linux-Development-Apps Digest #334, Volume #7    Fri, 13 Apr 01 17:13:09 EDT

Contents:
  socket++ 1.11 12Jan1997  ("ruben real (rR)")
  Re: howto properly access serial devices in Perl or C (Michael Meissner)
  Re: Call To Action: Help me help others. ("Steven J. Hathaway")
  Re: Development of Server in RedHat
  Using GDB on dynamically loaded code (Matthew Russell)
  Re: howto properly access serial devices in Perl or C (Ingo Ciechowski)
  Re: Maximum file size (Nate Eldredge)
  what is difference between "gcc" and "egcs cc"? ("liug")
  test ("liug")
  How can I write something like "ps" in C?  ("liug")
  Socket Status in /proc/net/tcp ("RJ Krawchuk")
  "segmentation fault" when runing more thread on Linux ("liug")

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

From: "ruben real (rR)" <[EMAIL PROTECTED]>
Subject: socket++ 1.11 12Jan1997 
Date: 13 Apr 2001 20:13:10 +0200

hi,



is there a version of Gnanasekaran Swaminathan´s (et al.) socket++ library (with 
exception support) which compiles cleanly under Linux?


thanks for all suggestions (patches for this edition) etc.


bye 
           ruben
-- 
_____________________________________________________________
NewsGroups Suchen, lesen, schreiben mit http://netnews.web.de

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

Crossposted-To: 
comp.os.linux.hardware,comp.os.linux.development.system,de.alt.comm.isdn4linux
Subject: Re: howto properly access serial devices in Perl or C
From: Michael Meissner <[EMAIL PROTECTED]>
Date: 13 Apr 2001 14:33:17 -0400

Ingo Ciechowski <[EMAIL PROTECTED]> writes:

> I'd like to access some serial device on my linux box bidirectionally, but 
> for some reason don't get connected to the device. Seems as if special 
> precautions are required...
> 
> 
> For now the program should simply output a couple of commands to /dev/modem 
> (shall later become /dev/ttyI0) and print out all replies on that line.
> 
> 
> 
> open (OUT, ">/dev/modem");
> open (IN, "</dev/modem");
> 
> print OUT "AT+FCLASS=8\n";
> 
> ### for some reason it already stucks here :-((
> 
> print OUT "AT&L*\n";
> print OUT "AT&E37*\n";
> 
> while(<IN>) {
>         print $_;
>         if(/RING/) {
>                 print OUT "ATA\n";
>                 print OUT "AT+VRX\n";
>                 $start = 1;
>         }
>         print FILE $_ if($start == 1);
> }
> 
> 
> 
> Hopefully someone can point me into the right direction?

The quick answer is open (FILE, "+</dev/modem").  Quoting from the fine
perlfunc man page which details the open function:

open FILEHANDLE,MODE,LIST
open FILEHANDLE,EXPR
open FILEHANDLE

        Opens the file whose filename is given by EXPR, and associates it with
        FILEHANDLE.  If FILEHANDLE is an expression, its value is used as the
        name of the real filehandle wanted.  (This is considered a symbolic
        reference, so `use strict 'refs'' should not be in effect.)

        If EXPR is omitted, the scalar variable of the same name as the
        FILEHANDLE contains the filename.  (Note that lexical variables--those
        declared with `my'--will not work for this purpose; so if you're using
        `my', specify EXPR in your call to open.) See the perlopentut manpage
        for a kinder, gentler explanation of opening files.

        If MODE is `'<'' or nothing, the file is opened for input.  If MODE is
        `'>'', the file is truncated and opened for output, being created if
        necessary.  If MODE is `'>>'', the file is opened for appending, again
        being created if necessary.  You can put a `'+'' in front of the `'>''
        or `'<'' to indicate that you want both read and write access to the
        file; thus `'+<'' is almost always preferred for read/write
        updates--the `'+>'' mode would clobber the file first.  You can't
        usually use either read-write mode for updating textfiles, since they
        have variable length records.  See the -i switch in the perlrun manpage
        for a better approach.  The file is created with permissions of `0666'
        modified by the process' `umask' value.

        These various prefixes correspond to the fopen(3) modes of `'r'',
        `'r+'', `'w'', `'w+'', `'a'', and `'a+''.

        In the 2-arguments (and 1-argument) form of the call the mode and
        filename should be concatenated (in this order), possibly separated by
        spaces.  It is possible to omit the mode if the mode is `'<''.

        If the filename begins with `'|'', the filename is interpreted as a
        command to which output is to be piped, and if the filename ends with a
        `'|'', the filename is interpreted as a command which pipes output to
        us.  See the Using open() for IPC entry in the perlipc manpage for more
        examples of this.  (You are not allowed to `open' to a command that
        pipes both in and out, but see the IPC::Open2 manpage, the IPC::Open3
        manpage, and the Bidirectional Communication with Another Process entry
        in the perlipc manpage for alternatives.)

        If MODE is `'|-'', the filename is interpreted as a command to which
        output is to be piped, and if MODE is `'-|'', the filename is
        interpreted as a command which pipes output to us.  In the 2-arguments
        (and 1-argument) form one should replace dash (`'-'') with the command.
        See the Using open() for IPC entry in the perlipc manpage for more
        examples of this.  (You are not allowed to `open' to a command that
        pipes both in and out, but see the IPC::Open2 manpage, the IPC::Open3
        manpage, and the Bidirectional Communication entry in the perlipc
        manpage for alternatives.)

        In the 2-arguments (and 1-argument) form opening `'-'' opens STDIN and
        opening `'>-'' opens STDOUT.

        Open returns nonzero upon success, the undefined value otherwise.  If
        the `open' involved a pipe, the return value happens to be the pid of
        the subprocess.

        If you're unfortunate enough to be running Perl on a system that
        distinguishes between text files and binary files (modern operating
        systems don't care), then you should check out the binmode entry
        elsewhere in this document for tips for dealing with this.  The key
        distinction between systems that need `binmode' and those that don't is
        their text file formats. Systems like Unix, MacOS, and Plan9, which
        delimit lines with a single character, and which encode that character
        in C as `"\n"', do not need `binmode'. The rest need it.

        When opening a file, it's usually a bad idea to continue normal
        execution if the request failed, so `open' is frequently used in
        connection with `die'.  Even if `die' won't do what you want (say, in a
        CGI script, where you want to make a nicely formatted error message
        (but there are modules that can help with that problem)) you should
        always check the return value from opening a file.  The infrequent
        exception is when working with an unopened filehandle is actually what
        you want to do.

By the way, if you are doing this, you probably want to check out the perl CPAN
function of Expect (from http://www.cpan.org/ and many other sites).  To give
you an example of Expect, here is a function that I wrote that I wrote to
control running a benchmark suite on a embedded processor connected via a
serial line.

sub runprog {
        my ($pathname)  = @_;
        my ($exp);
        my ($timeout);

        if (! open (TTY, "+<$opt_t")) {
                print "Could not open $opt_t: $!\n";
                return 0;
        }

        print ":::::::::: ", &short_timestamp (), " Running ", $pathname, "\n";

        $exp = Expect->exp_init (\*TTY);
        $exp->exp_stty ("raw -echo");
        $exp->match_max ($opt_c);

        if (defined $opt_l) {
                if ($opt_l eq "-") {
                        $exp->log_user (1);
                } else {
                        $exp->log_file ($opt_l);
                }
        }

        print $exp "\n";
        $exp->expect (5, '-re' => 'PMON[>]\s*$')                || die "Could not find 
monitor\n";

        print $exp "g\n";
        $exp->expect (5, '-re' => 'TH [+][>]\s*$')              || die "$pathname: did 
not start\n";

        if (defined ($opt_i)) {
                open (INPUT, "<$opt_i")                         || die "$pathname: 
$opt_i: $!\n";
                while (<INPUT>) {
                        print $exp $_;
                        $exp->expect (5, '-re' => 'TH [+][>]\s*$');
                }

                close (INPUT);
        }

        print $exp "g\n";

        $exp->expect ($opt_s, '-re' => 'TH [+][>]\s*$')         || die "$pathname: No 
end prompt\n";
        print $exp "exit\n";

        if ($exp->exp_before () =~ m!Iterations/Sec\s+=\s+([0-9.]+)!) {
                print ":::::::::: ", &short_timestamp (), " ", &tbl_commas (sprintf 
("%.2f", $1)), " Iterations/second\n";
        }
                        
        $exp->expect (5, '-re' => 'PMON[>]\s*$')                || die "Program did 
not finish\n";
        close ($exp);
        return 1;
}


-- 
Michael Meissner, Red Hat, Inc.  (GCC group)
PMB 198, 174 Littleton Road #3, Westford, Massachusetts 01886, USA
Work:     [EMAIL PROTECTED]           phone: +1 978-486-9304
Non-work: [EMAIL PROTECTED]   fax:   +1 978-692-4482

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

From: "Steven J. Hathaway" <[EMAIL PROTECTED]>
Subject: Re: Call To Action: Help me help others.
Date: Fri, 13 Apr 2001 11:37:26 -0700



"Peter T. Breuer" wrote:

> Jan Atle Ramsli <[EMAIL PROTECTED]> wrote:
> > Chris Falch wrote:
> > I guess the whole thing needs to be studied first: It is obvious what
> > 'help' means in such a small system, but what about now?
>
> Most editors offer this kind of thing. For example, "K" when the
> cursor is over a word will bring up the manpage. I imagine emacs
> does the same thing.
>
> > Help must become context sensitive in a new way - it must know what
> > 'kind' of help you are most likely to want.
>
> Nobody actually uses this, because there is no shortage of terminals
> (xterms) and it's more convenient to have one open for reading man
> pages on than to have it pop up in the editor! And nobody needs to
> refer to the manual the whole time.
>
> Peter

======
This takes me back to the MS-DOS days when I was using Norton Guides
and creating my own hot-key help files.  Regardless of MS-DOS program
being run -- if I could direct the cursor over a word and press a hot key
--
or press a hot key and type a word -- the Norton Guides system would
find help as associated with that word.

Context sensitive help would be available for various programming languages

suchas Macro, Cobol, PL1, Fortran, Pascal, C/C++, Ada, SmallTalk, Lisp,
and editor macros for EMACS, TECO, and debug commands for a variety
of system debuggers.

Thesaurus lookup was also available for documentation and news
presentations.

When MS-Windows 2.xx 3.xx came along, the availability of hot-key
interpretation of screen text (video buffer search) was thrashed.  For
several
years, I did development with two computers on my desk, one running
MS-DOS while the deployed systems technologies continued to march
along and become grossly incompatible with an old 8088 and 10MB disk
drive, and 30 MB external hard disk and CS600 tape backup system.

I wish you luck finding answers for your needs!
- Steve


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

From: <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.system
Subject: Re: Development of Server in RedHat
Date: Fri, 13 Apr 2001 11:39:58 -0700

To amplify Philip's comment, I think that 'Beginning linux programming' is a
misnomer for the books title, I found it has useful advanced information as
well.

"Philip Van Hoof" <[EMAIL PROTECTED]> wrote in message
news:lgOA6.30663$[EMAIL PROTECTED]...
> > 1.) How to develope an internet server tool, that means I want to create
> > a program that receives data from a client through the internet.
>
> Check the subdir 'chapter14' of this tarbal
> ftp://ftp.wrox.com/beginning/2971.tar.gz
> And/or buy the book "beginning linux programming"
>
> > 2.) The
> > data from the client I have to put in an mySQL Database.
>
> Then maybe it's not even nessesairy to build a server application
> at all. With MySQL you can connect with the clients to any
> online server. Just make sure that the Host permission of the
> user who is going to connect to the MySQL server is set to %
> and port 3306 or 3307 (not sure) on the server is open (udp/tcp).
>
> You can use Kylix or Delphi using mysql.pas (search with google)
> and for kylix there are build in possibilities for working
> with mysql. Both are for rapid application development ofcourse.
> If you have more time :) and you want to build good applications
> you should start learning C and learn how to use the mysql
> API for C or .. C++ . You van find loads of information on
> API's for programming MySQL clients on mysql.com. If you are
> going to build a server application between the mysql server
> and the client then the server program will have to be
> programmed as client of the mysql server and as server for
> the actual client. Only difference is that the server must
> connect to the localhost mysqld ..
>
> So
>
> or you use :
>
> client -internet-> your server app -localhost-> mysqld
>
> or
>
> client -internet-> mysqld
>
>
> > 3.) How can I
> > make the server run all the time, when the linux-server starts.
>
> This depends on your distro ..
> for Redhat you have a dir called
> /etc/rc.d/rc$RUNLEVEL.d/
> where $RUNLEVEL is a number from 0 to 6. If your redhat
> starts in X mode then this runlevel is 5. Else it's
> probably runlevel 2. Runlevel 1 is single mode (when you
> run LILO: linux single) and 6 is reboot and shutdown
> runlevel. Redhat will start all scripts that start with
> the letter S in that directory.
>
> in pseudo code this happens at bootup :
>
> a) get the runlevel from /etc/inittab and put it in #RUNLEVEL
> b)
> $MYLIST = `ls /etc/rc.d/rc$RUNLEVEL.d/S*`
> for each item in $MYLIST
> do
>   exev $item start
> fi
>
> Now .. it's a bit more complicated ..
>
> In linux you have symlinks so the redhat folks made another dir
> called /etc/rc.d/init.d where all the possible scripts resist..
> Redhat has some tools that allow you to manage the startup
> scripts using some gfx-gui/text-gui tools.. and to make this
> possible they use symlinks (well most distro's use it) this way :
>
> They symlink
> /etc/rc.d/rc2.d/S01something to /etc/rc.d/init.d/something
> if the script must be executed at startup ... and
> /etc/rc.d/rc2.d/K01something to /etc/rc.d/init.d/something
> if the script must not be executed but only showed in these
> tools..
>
> A symlink is NOT like a shortcut in Windows.. well actually
> it is.. but its much more powerfull. It's a link to a file..
> Know what.. Read the man page of ln :)  "man ln"
>
> > That means where can I find some samples or other information on these
> > two problems. In fact I am also really interested, if this is a complex
> > problem in linux and which libarys ( in C++ ) I could use to simplify my
>
> So I suggest that you checkout mysql.com for API's to use with MySQL
> and programming languages like C and C++ 'or' kylix and Delphi depending
> how much time you get for this job. Kylix and Delphi == not much
> time to learn and to develop your application. And you can port
> Kylix and Delphi applications to and from windows/linux.. Also kylix
> is VERY new .. http://www.borland.com/kylix and still pretty
> expensive. ($1500). Or if you care more about the quality of the
> application.. I suggest that you learn C/C++ and the API's which you
> can fetch from mysql.com...
>
> > work. I know that I can search with some searchengines, but I am a
> > really newbie in linux and so have no detailed idea for what to search
> > exactly.
>
>
>
> > P.S. Sorry for my bad english
>
> P.S. Sorry for "my" bad english to :-)
>
>
> --
> Philip van Hoof aka freax (http://www.freax.eu.org)
> irc: irc.openprojects.net mailto:freax @ pandora.be



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

From: Matthew Russell <[EMAIL PROTECTED]>
Subject: Using GDB on dynamically loaded code
Date: 13 Apr 2001 19:04:21 GMT

How can I use Gnu gdb to step into my dynamically loaded code? I'm using
glib's g_module_* functions, which I think wrap dlopen etc. When I run my
program from within gdb, I get this message:

warning: Unable to find dynamic linker breakpoint function.
GDB will be unable to debug shared library initializers
and track explicitly loaded dynamic code.

Any help would be gratefully received!

Matthew R.

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

From: Ingo Ciechowski <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.hardware,comp.os.linux.development.system,de.alt.comm.isdn4linux
Subject: Re: howto properly access serial devices in Perl or C
Date: Fri, 13 Apr 2001 21:37:29 +0200

On Fri, 13 Apr 2001 20:33:17 +0200, Michael Meissner wrote
(in message <[EMAIL PROTECTED]>):

> open (FILE, "+</dev/modem")

great. this works for /dev/modem - but for whatever reason I didn't get it to 
work with /dev/ttyI0 (which is provided by isdn4linix).

any idea?


-- 

Ingo
[EMAIL PROTECTED]


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

From: Nate Eldredge <[EMAIL PROTECTED]>
Subject: Re: Maximum file size
Date: 13 Apr 2001 12:40:17 -0700

"Vincent Rouet" <[EMAIL PROTECTED]> writes:

> It seems that the maximum file size is 2 147 483 647 (32 signed bits coding)
> with ext2.
> Is there something to do to change this and increase this limit ?

Upgrade to a 2.4 kernel.  There may also be patches for 2.2.

You may also need a newer libc, depending on your current
version. glibc 2.2.x certainly works.

-- 

Nate Eldredge
[EMAIL PROTECTED]

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

From: "liug" <[EMAIL PROTECTED]>
Subject: what is difference between "gcc" and "egcs cc"?
Date: Fri, 13 Apr 2001 12:04:47 -0400

Hi,
  What is the difference between "gcc" and "egcs cc"?  Seems like there are
some relationship betweent this two.
  Thanks





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

From: "liug" <[EMAIL PROTECTED]>
Subject: test
Date: Fri, 13 Apr 2001 12:20:31 -0400





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

From: "liug" <[EMAIL PROTECTED]>
Subject: How can I write something like "ps" in C? 
Date: Fri, 13 Apr 2001 12:37:41 -0400





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

From: "RJ Krawchuk" <[EMAIL PROTECTED]>
Subject: Socket Status in /proc/net/tcp
Date: Fri, 13 Apr 2001 17:07:10 -0700

Hi,

I am writing a program that reads the /proc directories. I have two
questions:
1. Where can I find out the meaning of the socket status of the
/proc/net/tcp table. If a user is logged in to a service, it changes from 0A
to 01. Are there other type of status. I am guessing it is wating and
active.
2. What can I use to create this programmatically.

Any help would be appreciative.

Thank you.






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

From: "liug" <[EMAIL PROTECTED]>
Subject: "segmentation fault" when runing more thread on Linux
Date: Fri, 13 Apr 2001 17:04:39 -0400

Hi,
  I am using RedHat 6.2, gcc 2.95.2 (libc.so.6).
  I have a problem runing threads on Linux. I build the application with the
following line:
  g++  -D_REENTRANT -D_UNIX -DXML_LINUX -o tapp testt.c unixfileio.cpp \
          rtfint.cpp rtf.cpp -lpthread

  The program is creating a certain number of threads, then wait for all
threads (pthread_join()) it creates to finish.   When I create less than 40
threads, everything works fine. However when I creates more than 40 threads,
I got "Segmentation fault".  It doesn't complain any thing in my program at
all.  I am sure all the threads the main thread created are finished and
they all have done their job( I keep track of this using printf()),  the
problem here is caused by main thread exiting.  I really don't know what can
cause such problem.  The following is the backtrace info when I created 41
threads.

(gdb) set arg 1 41
(gdb) r
Starting program: /home/liug/aaa/tapp 1 41
rtfint.cpp: rtf_config_env = /home/liug/aaa/RtfConfig.xml
[New Thread 1313 (manager thread)]
[New Thread 1311 (initial thread)]
....
Program received signal SIGSEGV, Segmentation fault.
0x401ca0d6 in chunk_free (ar_ptr=0x4025ed60, p=0x80a1ba8) at malloc.c:3097
3097    malloc.c: No such file or directory.
(gdb)
(gdb) bt
#0  0x401ca0d6 in chunk_free (ar_ptr=0x4025ed60, p=0x80a1ba8) at
malloc.c:3097
#1  0x401c9fba in __libc_free (mem=0x80a1c88) at malloc.c:3023
#2  0x402506e1 in __deregister_frame_info (begin=0x806f008) at
../../gcc/frame.c:581
#3  0x804c873 in __do_global_dtors_aux ()
#4  0x806c3c9 in _fini ()
#5  0x4019125a in exit (status=0) at exit.c:57
#6  0x401889d1 in __libc_start_main () at ../sysdeps/generic/libc-start.c:92





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


** FOR YOUR REFERENCE **

The service address, to which questions about the list itself and requests
to be added to or deleted from it should be directed, is:

    Internet: [EMAIL PROTECTED]

You can send mail to the entire list by posting to the
comp.os.linux.development.apps newsgroup.

Linux may be obtained via one of these FTP sites:
    ftp.funet.fi                                pub/Linux
    tsx-11.mit.edu                              pub/linux
    sunsite.unc.edu                             pub/Linux

End of Linux-Development-Apps Digest
******************************

Reply via email to