Linux-Development-Apps Digest #454, Volume #7     Tue, 5 Jun 01 16:13:11 EDT

Contents:
  Re: Newt problems (Thomas Dickey)
  Re: Porting solaris software to Linux (Dragan Cvetkovic)
  Re: Problem receiving UDP messages (Jan Atle Ramsli)
  Re: tabstops (Bob Beaty)
  on press events (R@FooN)
  Re: Porting solaris software to Linux (Grant Edwards)
  Re: Porting solaris software to Linux
  Re: [Q] How do I get html file in C-network programming? (agent_sheep)
  Re: How to launch command line tool from c source code? (Jan Atle Ramsli)
  Re: Porting solaris software to Linux ("liug")
  Re: Development under Linux (Daniel Kaminsky)
  Critical Sections (Konstantin Seiler)
  Re: Critical Sections (Aleksandr Morgulis)
  Re: Cyclic file (Nate Eldredge)
  Re: Critical Sections (Nate Eldredge)
  Re: Critical Sections ("Timur Aydin")
  Re: Newt problems ("Millo Meneghini")
  strace ltrace backtrace
  Shared Library exported symbols ("Timur Aydin")
  cooledit installation (Sam Rosenfeld)
  getopt + optional parameter (Felix Natter)
  Re: reading files that other processes make
  Re: ftp connections
  Re: global variable in shared library? (Ulrich Weigand)
  Re: Shared Library exported symbols (Ulrich Weigand)

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

From: Thomas Dickey <[EMAIL PROTECTED]>
Subject: Re: Newt problems
Date: 5 Jun 2001 13:13:19 GMT

Millo Meneghini <[EMAIL PROTECTED]> wrote:
> Well, because I'd already prepared my software application using this
> library when I discovered that it has so many problems!
> And it's also more beautiful to see than ncurses, that  now I must use....

hmm (the same characters get sent to the screen: should look the same)

-- 
Thomas E. Dickey <[EMAIL PROTECTED]> <[EMAIL PROTECTED]>
http://dickey.his.com
ftp://dickey.his.com

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

Crossposted-To: comp.os.linux.development.system,comp.unix.programmer,comp.unix.solaris
Subject: Re: Porting solaris software to Linux
From: Dragan Cvetkovic <[EMAIL PROTECTED]>
Reply-To: [EMAIL PROTECTED]
Date: 05 Jun 2001 09:35:05 -0400

[EMAIL PROTECTED] (phil) writes:
> 
> One huge section that is completely different on Linux and Solaris,
> is threads. Solaris has it's own thread Library, while Linux uses
> it's POSIX thread library.


Well, Solaris does have its own thread library, but also has POSIX one, so
all POSIX thread functions are supported. 

> 
> Semaphores are another area where this happens again, Linux
> conforming somewhat to the POSIX standard and Solaris with it's own
> semaphore functions.

They both support SYSV IPC semaphores (semctl, semget, semop) which most of
the people still use. I didn't know that Linux supports POSIX ones
(sem_close, sem_init, sem_post etc.), but, since I have man pages for them
it obviously does :-)

Bye, Dragan

-- 
Dragan Cvetkovic, 

To be or not to be is true. G. Boole

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

Date: Tue, 05 Jun 2001 17:43:00 +0200
From: Jan Atle Ramsli <[EMAIL PROTECTED]>
Subject: Re: Problem receiving UDP messages

Ross Mills wrote:
> 
> Phil,
> 
> Thanks for the response.
> 
> > Are you setting the SO_BROADCAST option on the sending socket?
> 
> The broadcasting app is written in java.  
I am doing some experiments with Java sockets.
I have copied your code, could I see the Java code fragment that
interacts with this C-code?

Thanks, Atle
Atle

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

From: [EMAIL PROTECTED] (Bob Beaty)
Subject: Re: tabstops
Reply-To: [EMAIL PROTECTED]
Date: Tue, 05 Jun 2001 14:20:36 GMT

Charles Wilkins wrote:
> I am not sure this pertains to vi or bash, but when i write scripts,
> the tabstops are set at 8 spaces.  How can I reset the tab stops to a
> lower number? 

In ~/.vimrc put the following:
        :set ts=4
which will set the tab stops to 4 spaces.

                        Thanks,
                          Bob   ([EMAIL PROTECTED]) 
                        The Man from S.P.U.D. 
                        We will write no code before it's designed.  


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

From: R@FooN <[EMAIL PROTECTED]>
Subject: on press events
Reply-To: [EMAIL PROTECTED]
Date: Tue, 5 Jun 2001 18:46:18 +0200



I want , if i press a button on my keyboard a function starts en when i 
release the button the function stops , in my program.
But i don't know how to do that :-(
can someone help me please 
i'm using c++

Thankx ,
R@FooN


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

From: [EMAIL PROTECTED] (Grant Edwards)
Crossposted-To: comp.os.linux.development.system,comp.unix.programmer,comp.unix.solaris
Subject: Re: Porting solaris software to Linux
Date: Tue, 05 Jun 2001 14:50:58 GMT

In article <9fhrtj$cho$[EMAIL PROTECTED]>, jamal wrote:

>I am new in linux or unix programming in general.
>My company has an application written for Windows and Solaris.
>We plan to port it to Linux. 

First, I'd get it to build under Solaris with Gnu tools (gcc,
gnu make).

Once you've got it ported to gcc, then try moving it to Linux.

That will involve various (relatively minor, in my experience)
libary incompatibilities.  One thing that I always ran into
were small differences in the handling of signals: whether
system calls are restarted, and wheter signal handlers have to
be re-installed with every signal.  It's possible to write
signal code that works right on both systems (without #ifdefs),
but the typical way of doing things on one system doesn't work
quite right on the other.

-- 
Grant Edwards                   grante             Yow!  Are you mentally here
                                  at               at Pizza Hut??
                               visi.com            

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

From: <[EMAIL PROTECTED]>
Subject: Re: Porting solaris software to Linux
Date: 5 Jun 2001 15:04:59 GMT

Can you elaborate a little bit on the Solaris threads/semaphore issues? There is
a libposix4 library shipped with solaris and solaris conforms to the pthreads
interface. It also includes all semaphore functions like sem_post, sem_wait etc.
which work accross LWPs. The only thing I would watch for is enabling
PTHREAD_SCOPE SYSTEM in pthread_attr_setscope() and using the attribute on
pthread_create(). In my experience, if you do not do this, the thread created on
Solaris will not be a kernel thread but a user thread which is scheduled
differently. On Linux it doesnt hurt since the only supported option is 
PTHREAD_SCOPE_SYSTEM

At least my experience, I might be wrong :)

Best regards,
Ognen

-- 
Ognen Duzlevski
Plant Biotechnology Institute
National Research Council of Canada
Bioinformatics group

> Hi Jamal,
> Having generally ported applications from Liunx *to* Solaris, I'll
> try and explain the differences I have encountered..

> One good thing about this could be GNU. If you have been using GNU
> development tools on Solaris, your work is made much easier.

> One huge section that is completely different on Linux and Solaris,
> is threads. Solaris has it's own thread Library, while Linux uses
> it's POSIX thread library.

> Semaphores are another area where this happens again, Linux
> conforming somewhat to the POSIX standard and Solaris with it's own
> semaphore functions.

> What kind of application is it, what kind of libraries does it
> use.. that kind of thing.
> Phil.

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

From: [EMAIL PROTECTED] (agent_sheep)
Crossposted-To: 
comp.os.linux.networking,comp.os.linux.development,linux.dev.apps,linux.dev.c-programming
Subject: Re: [Q] How do I get html file in C-network programming?
Date: 5 Jun 2001 08:15:15 -0700

use this link to learn socketcoding:

http://www.ecst.csuchico.edu/~beej/guide/net/html/

And then read the http rfc about how the request must look. I tried it
once and it was really easy.

> Hi.
> I am a beginner of c-network progam in Linux.
> I want to make a simple Internet program that can get a html file using
> given URL.
> I can't find any documentation about that.
> Thank you.

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

Date: Tue, 05 Jun 2001 19:39:47 +0200
From: Jan Atle Ramsli <[EMAIL PROTECTED]>
Subject: Re: How to launch command line tool from c source code?

Ángel Suárez Rivero wrote:
> 
> Holger wrote:
> >
> > Hi All,
> >
> > How to launch command line tools from c source code? I am using RH 7.0. Any
> > example source code would be great.

>From c source code is difficult - but from compiled code it is easy :-)

You may want to check out exec (man 3 exec) as well.

What is it you want to do?

Atle

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

From: "liug" <[EMAIL PROTECTED]>
Subject: Re: Porting solaris software to Linux
Date: Tue, 5 Jun 2001 09:33:41 -0400

> One huge section that is completely different on Linux and Solaris,
> is threads. Solaris has it's own thread Library, while Linux uses
> it's POSIX thread library.

Red Hat Linux doesn't seem fully support POSIX thread library. At lease
sem_open() is not implemented at RH 6.2.


> Semaphores are another area where this happens again, Linux
> conforming somewhat to the POSIX standard and Solaris with it's own
> semaphore functions.
>
> What kind of application is it, what kind of libraries does it
> use.. that kind of thing.
> Phil.



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

From: Daniel Kaminsky <[EMAIL PROTECTED]>
Subject: Re: Development under Linux
Date: Tue, 05 Jun 2001 18:58:18 +0200

Hi!

Thanks for replies...
After i got some advice from friends, newsgroups and so on, I decided to
write this application in Java. It will run without any problem on
Windows.


Gru=DF Daniel

-- =

The worst day finswimming is better than
the best day working.

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

From: Konstantin Seiler <[EMAIL PROTECTED]>
Subject: Critical Sections
Date: Tue, 5 Jun 2001 19:03:56 +0200
Reply-To: [EMAIL PROTECTED]

I'm looking for something similar to the Critical Sections used by Windows.
When writing a multi-thread-program the threads sometimes have to share 
certain parts of the memory. Now I have to ensure that if one thread is 
manipulating that Memory the other one doesn't (and if necessary waits). 
Does anybody know how that is done with Linux?

Konstantin


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

From: Aleksandr Morgulis <[EMAIL PROTECTED]>
Subject: Re: Critical Sections
Date: Tue, 5 Jun 2001 13:15:10 -0400
Reply-To: [EMAIL PROTECTED]

What you need is mutex. Look at the documentation for POSIX threads to find 
out about them. I think the glibc info page should contain this information.

AM

Konstantin Seiler wrote:

> I'm looking for something similar to the Critical Sections used by
> Windows. When writing a multi-thread-program the threads sometimes have to
> share certain parts of the memory. Now I have to ensure that if one thread
> is manipulating that Memory the other one doesn't (and if necessary
> waits). Does anybody know how that is done with Linux?
> 
> Konstantin
> 
> 


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

From: Nate Eldredge <[EMAIL PROTECTED]>
Subject: Re: Cyclic file
Date: 05 Jun 2001 10:30:55 -0700

"Moshe Shimoni" <[EMAIL PROTECTED]> writes:

> Hello all,
> I need to write data from a process into a file. I don't want the file size
> to grow too much.
> I can't just truncate the file because I need the latest data. Let's say I
> need always the last 1MB of the file.
> I can rewind the FILE cursor after 1MB but it will not be clear to the user
> to read the file.
> I can also fork and run a system tail command and try to play with it but it
> doesn't seem so simple.
> Isn't there a simple way which manages this thing?

The way this is often done is to rotate the files.  Every so often,
close your file, move it somewhere else (say, an archive directory),
and start a new one.  Then delete the oldest file in the archive
directory.  By choosing appropriately how big the files get before you
switch, and how many old files to keep, you can determine how much
data is kept.

-- 

Nate Eldredge
[EMAIL PROTECTED]

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

From: Nate Eldredge <[EMAIL PROTECTED]>
Subject: Re: Critical Sections
Date: 05 Jun 2001 10:31:45 -0700

Konstantin Seiler <[EMAIL PROTECTED]> writes:

> I'm looking for something similar to the Critical Sections used by Windows.
> When writing a multi-thread-program the threads sometimes have to share 
> certain parts of the memory. Now I have to ensure that if one thread is 
> manipulating that Memory the other one doesn't (and if necessary waits). 
> Does anybody know how that is done with Linux?

man pthread_mutex_init

-- 

Nate Eldredge
[EMAIL PROTECTED]

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

From: "Timur Aydin" <[EMAIL PROTECTED]>
Subject: Re: Critical Sections
Date: Tue, 5 Jun 2001 13:51:53 -0400


"Konstantin Seiler" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> I'm looking for something similar to the Critical Sections used by
Windows.

The closest that you can come to a critical section is the pthread_mutex_t.
However, note that pthread_mutex_t can be set up to support or not to
support recursive locking, while win32 critical sections are always
recursive. Also, recent versions of C runtime library support timed waits on
mutexes using pthread_mutex_timedwait, while a critical section doesn't have
a timeout. I don't know how the two compare performance wise, but if the
amount of time that the shared resource is kept locked is very short (which
it should be), their overhead should be negligible.

However, when examining the CRITICAL_SECTION data structure, there are some
fields that suggest that the critical section can sometimes "degrade" to a
kernel object (maybe if the wait time is too long?). Does anybody else know
more about this? Is there a similar mechanism for pthread mutexes?

Timur.



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

From: "Millo Meneghini" <[EMAIL PROTECTED]>
Subject: Re: Newt problems
Date: Tue, 05 Jun 2001 18:04:34 GMT

;-))))
"more beautiful" I mean "simpler" to use...
Bye
Millo



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

Subject: strace ltrace backtrace
From:  <Use-Author-Address-Header@[127.1]>
Date: Tue, 5 Jun 2001 14:07:40 -0400

Greetings Linux Lords and Ladies

I am looking for a tool that combines the best features of strace , ltrace
and gdb's backtrace feature.

mpatrol has some of the features I am looking for but it only traces memory
allocation / freeing.

I have dug through freshmeat and not found what I am looking for.

Brian Fennell
bfennell@bigchalkDOTcom
Please reply via e-mail as well as posting,  I have limited usenet access
right now.




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

From: "Timur Aydin" <[EMAIL PROTECTED]>
Subject: Shared Library exported symbols
Date: Tue, 5 Jun 2001 14:21:45 -0400

Hi everybody,

I was looking into a method by which I could have functions be called at
library loadtime and library unload time. I also wanted to use the same
source code for linux and win32 (so no _init, _fini and no DllMain and
definitely no platform specific hacks). The libraries were based on C++, so
I though I would define a global object so that its constructor would be
called at library load time and the destructor at library unload time. Here
it goes:

class cLibInit
{
public:
   cLibInit(void (*pInitFunc)(), void (*pDoneFunc)())
      :pInitFunc(pInitFunc), pDoneFunc(pDoneFunc)
   {
      pInitFunc();
   }

   ~cLibInit()
   {
      pDoneFunc();
   }

private:
   void (*pInitFunc)();
   void (*pDoneFunc)();
};

Then, in a source module of the library, I would define my load and unload
handlers and a global object:

void LibLoad()
{
   ...
}

void LibUnoad()
{
   ...
}

cLibInit Lib(LibLoad, LibUnload);

Then I linked the library with my application and as expected, it worked.
So, I started working on another library, using the same mechanism. The
first shared library was using the second shared library:

App (uses) libFirst.so (uses) libSecond.so

Now my problems started. I was getting crashes when I used runtime library
functions in LibLoad and LibUnload of libSecond.so. When I made a reference
to errno, it was crashing, too. It looked like libSecond.so did not have any
runtime library support available. After a lengthy investigation, I found
out that libFirst.so's LibLoad and LibUnload were "masking" or should I say
"hiding" the LibLoad and LibUnload of libSecond.so. Therefore, I made all
the LibLoad and LinUnload functions and the global object "static". Now
everything is fine.

But now I'm thinking... What if I had multiple libraries and each had a
global variable or a function with the same name? This would not be uncommon
at all, because you would want to use same names for variables and functions
that do the same thing. In the above case, I got away by using "static", but
in other cases where multiple source modules need to use a global variable
or a function, I can't use "static".

Somehow, I have to make the symbol global for all modules in the library,
but invisible to other libraries and the application.

Any suggestions?

Timur.




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

From: Sam Rosenfeld <[EMAIL PROTECTED]>
Subject: cooledit installation
Date: Tue, 05 Jun 2001 18:16:43 GMT

I have tried to install cooledit 3.17.4 but it will not compile.  Error
reads
something like " cannot find libCw.so.1".  Well, neither can
I--anywhere.

Any suggestions?

Thanks,
sam


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

From: Felix Natter <[EMAIL PROTECTED]>
Subject: getopt + optional parameter
Date: 05 Jun 2001 19:00:14 +0200

hi,

I usually use optarg to get a required parameter for an option,
but if I declare an option with an optional argument (i.e. "c::"),
optarg is NULL even if an argument is specified.

Is there another way to get an argument for an option
(optarg is a GNU extension anyway) ?

thanks,

-- 
Felix Natter

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

From: [EMAIL PROTECTED] ()
Subject: Re: reading files that other processes make
Date: Tue, 05 Jun 2001 19:03:31 -0000

In article <[EMAIL PROTECTED]>,
N. Yeamans <[EMAIL PROTECTED]> wrote:

>Sounds like you want file locking.  Read 'man flock'

Doing a rename after the writes are finished is much easier.

--
http://www.spinics.net/linux/

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

From: [EMAIL PROTECTED] ()
Subject: Re: ftp connections
Date: Tue, 05 Jun 2001 19:07:06 -0000

In article <9fe6e7$rrc$[EMAIL PROTECTED]>,
O de Zwart <[EMAIL PROTECTED]> wrote:

>Does anyone have some simple code of how to communicate with an ftpd after
>the connection is made with sockets?
>how do I recieve responses from the server?

Looks at the source for an ftp client.  You should also read
the rfc that documents the ftp protocol.

--
http://www.spinics.net/linux/

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

From: [EMAIL PROTECTED] (Ulrich Weigand)
Subject: Re: global variable in shared library?
Date: 5 Jun 2001 21:06:59 +0200

Wong Ka Chun <[EMAIL PROTECTED]> writes:

>  So, it means that global variables in shared library are indeed visible
>to application. But it is not possible for one to assign a name which may
>not clash with someone else application. In Win32, global variable in DLL
>is not visible to application unless you explicity put it to a shared
>memory region. Why this is not done similar under Linux?

(Actually, visibility to the application has nothing to do with shared 
memory; this is just a matter of whether the symbol is exported using
a .DEF file or a declspec(dllexport) statement ...)

The whole concept of shared libraries on Linux (and other Unixes) is that
a shared library behaves exactly the same as a statically linked library,
only with different performance characteristics (i.e. it's somewhat slower
when used only once, but saves a lot of memory when lots of applications
use the library at the same time).

The toolchain actually goes through a number of contortions to implement
this behaviour; it's really not trivial (e.g. the initial values of 
variables defined in the library but used in the application are copied
to the .dynbss slots; for function pointer comparisons everybody uses 
the address of the PLT slot for the function in the main application,
not the address of the function itself; etc.).  But while the internals
are complex, the user-visible behaviour is easy to describe: just the
same as statically linking.

In Windows, on the other hand, DLLs have a quite different user-visible
behaviour that statically linked libraries.  This makes them easier to
implement, however the user has to be aware of the fact that it's not
a static library (i.e. writing .DEF files and/or using dllexport/
dllimport, possibly fiddling around with ordinals, etc.).

On the one hand, this behaviour has disadvantages compared to the Unix
model: you have two quite different user-visible models of linking to
consider.  On the other hand, this makes it possible to use DLLs for a
second purpose at the same time: not just to solve performance problems
by avoiding multiple copies of the same library loaded into memory, but
also to provide for name space encapsulation.

If you want to do this sort of name space encapsulation on Unix, you have 
to use some other mechanism -- shared libraries won't do it for you. 
However, if you use something else, that will work also when when you 
are statically linking ...   As the C language doesn't provide for name
spaces, the traditional method has always been to just use a common name 
prefix for every module:  if you are implementing the 'foo' module, 
every global variable or function should have a name that starts with 
foo_.  If you choose 'foo' distinctive enough, that will work for all
practical purposes ...


B.t.w. nowadays Unix toolchains (including the GNU toolchain used on Linux)
have introduced various additions to the simple model described above.
With the GNU linker, it is in fact now possible to decide on a symbol-
by-symbol basis which global symbols should be visible outside a shared
library and which ones not.

To do so, you'll need to create a 'version script' which looks like:

VERSION_TAG {
  global:
     foo;
  local:
     bar;
};

where you list under 'global' those names that should be visible outside
and under 'local' those that shouldn't; you can use wildcards.  You then
specify the version script as argument to the link process. Check out the 
ld info pages ('VERSION command') for more details.

Note that this is not portable; other linkers on other Unix platforms
may offer similar features, but the syntax will be completely different ...

-- 
  Dr. Ulrich Weigand
  [EMAIL PROTECTED]

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

From: [EMAIL PROTECTED] (Ulrich Weigand)
Subject: Re: Shared Library exported symbols
Date: 5 Jun 2001 22:01:42 +0200

"Timur Aydin" <[EMAIL PROTECTED]> writes:

>But now I'm thinking... What if I had multiple libraries and each had a
>global variable or a function with the same name? This would not be uncommon
>at all, because you would want to use same names for variables and functions
>that do the same thing. In the above case, I got away by using "static", but
>in other cases where multiple source modules need to use a global variable
>or a function, I can't use "static".

>Somehow, I have to make the symbol global for all modules in the library,
>but invisible to other libraries and the application.

Have a look at the response I just posted to the thread 'global variable
in shared library?'.  The short version is: if it wouldn't work if you'd
link everything together statically, it won't work if you link it together
dynamically, because dynamic linking is explicitly designed so as to have
the same user-visible effects as static linking on Unix / Linux.

If you *really* need to do this, you might use version scripts, but these
are inherently non-portable ...

-- 
  Dr. Ulrich Weigand
  [EMAIL PROTECTED]

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


** 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