Linux-Development-Sys Digest #62, Volume #7 Tue, 17 Aug 99 15:13:58 EDT
Contents:
problem with serialprogramming (juergen leeb)
Re: Printing in Linux (Gordon Haverland)
Re: Problem with device driver. HELP ([EMAIL PROTECTED])
Re: kernel 2.2.11 compile problem (Guilhem Tardy)
Re: ldd with weird output (Karl Heyes)
Re: fork() question ("Ted Pavlic")
Re: Problems installing Interrupt handler (Peter Pointner)
Re: threads ("Bill Burris")
Re: why not C++? (Bjorn Reese)
Re: Printing in Linux (Chris)
[Req] Pascal tools/source/info related to Linux (Bill M. Catambay)
Re: [Req] Pascal tools/source/info related to Linux (Bob Tennent)
Re: Code for security: chroot and child processes (brian moore)
Re: Deadly optimization bug (all versions!) (James Stevenson)
----------------------------------------------------------------------------
Date: Tue, 17 Aug 1999 15:19:04 +0200
From: juergen leeb <[EMAIL PROTECTED]>
Subject: problem with serialprogramming
i have to read a serialport.
i use termios.h, but if there is a break linux read 0.
i dont want to have this.
what can i do??
------------------------------
From: Gordon Haverland <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Printing in Linux
Date: Tue, 17 Aug 1999 06:15:16 -0600
Norm Dresner wrote:
>
> I need to write a c-program to print to the "default" printer which is
> usually (and the Printing-HOWO confirms this) denoted as the device "lp".
> But /proc/lp contains no device lp. The printer is installed and working.
> I can print from a file with the "lp <filename>" command and if I
> explicitly code the device name "/dev/lp0" into the program it will also
> print correctly.
>
> The main question is how can I tell if any printer is installed from a
> c-program and what to call it when I open it for writing?
Usually, all control of the printer is via the print
spooling software,
which is an IP resource. Let's say you explicitly write to
/dev/lp0,
and another program from another user also starts writing to
/dev/lp0
at the same time (neighbouring time slices or something like
that).
What is going to happen? Better to open a socket to the
appropriate
port number and write your strem of data via the print
spooling system.
Gordon Haverland
#include <disclaimer.h>
------------------------------
From: [EMAIL PROTECTED]
Subject: Re: Problem with device driver. HELP
Date: Tue, 17 Aug 1999 13:47:19 GMT
On Tue, 17 Aug 1999 00:04:22 GMT, [EMAIL PROTECTED] (Kaz
Kylheku) wrote:
>On Mon, 16 Aug 1999 21:49:45 GMT, Peter Pointner <[EMAIL PROTECTED]> wrote:
>>[EMAIL PROTECTED] wrote:
>>> When i try to compile this charter device driver i get this error:
>>> pbus.c: In function `pb_open':
>>> pbus.c:70: wrong type argument to bit-complement
>>
>>> Here is the code:
>>> while((lock[dev] >> func) & 1) {
>>> interruptible_sleep_on(&pb_WaitQ);
>>> line 70-> if(current->signal & ~current->blocked) {
>>> MOD_DEC_USE_COUNT;
>>> return -EINTR;
>>> }
>>> }
>>> What is wrong?
>>
>>You are using a 2.2.x kernel? Then use
>> if (signal_pending(current))
>>instead of your code. AFAIK current->blocked has been changed
>>to an array to make more than 32 signals possible, and ~ can't
>>be used on that.
>
>Also, what about the possible race between testing the condition and sleeping?
>I.e. what if the condition ``(lock[dev] >> func) & 1'' becomes false after it
>is tested but before suspension? What then? The problem is that
>interruptible_sleep_on both enqueues the task and calls the scheduler in one
>operation. If the wake up goes off before the task is enqueued, it will be
>missed.
But wake_up can't be called before the schedule() call because this
code is running in kernel mode, right?
------------------------------
From: Guilhem Tardy <[EMAIL PROTECTED]>
Subject: Re: kernel 2.2.11 compile problem
Date: Tue, 17 Aug 1999 10:15:11 -0400
Hi!
Did you modify the symbolic link /usr/src/linux to point to the new
directory (e.g. /usr/src/linux-2.2.11)?
There's some more directories (i.e. /usr/include/asm and
/usr/include/linux), but these usually point to subdirectories of
/usr/src/linux (instead of the real non-symbolic location of your
kernel), so that /usr/src/linux is the only thing you have to change
everytime you increase the version of your kernel.
And don't forget to run "make xconfig" prior to compilation, because a
simple copy of a previous ".config" file doesn't make it (there's some
new parameters).
--
Guilhem Tardy phone: (613) 993-8232
Communications Research Center email: [EMAIL PROTECTED]
Network Systems and Technologies web: http://www.crc.ca/
------------------------------
From: Karl Heyes <[EMAIL PROTECTED]>
Subject: Re: ldd with weird output
Date: Tue, 17 Aug 1999 15:50:02 +0100
Axel Reinhold wrote:
> Hi,
>
> playing around with glibc on RH5 gave me some strange behaviour of
> ldd/ldconfig/ld.so. I need libc5 compatibility, so I installed the
> /usr/i486-linux-libc5/lib/... libraies and set up /etc/ld.so.conf
> correctly.
> So far so good. But when I ask ldd for example on a libc5 based sendmail
> binary I tells me:
>
> [root@hammer sendmail]# ldd sendmail
> libdb.so.2 => /lib/libdb.so.2 (0x40002000)
> libc.so.5 => /lib/libc.so.5 (0x40010000)
> libc.so.6 => /lib/libc.so.6 (0x400d9000)
> /lib/ld-linux.so.1 => /lib/ld-linux.so.2 (0x00000000)
>
sendmail will bind to the libc.so.5 lib first. Although I'm suprised that
libc.so.6 actually shows up.
ls -l /lib/libc.so.5
>
> I _have_ installed a libc5 compatible libdb.so.2:
>
> [root@hammer sendmail]# ldconfig -p|grep libdb
> libdb.so.2 (ELF) => /usr/i486-linux-libc5/lib/libdb.so.2
> libdb.so.2 (ELF-libc6) => /lib/libdb.so.2
> libdb.so.1 (DLL) => /usr/i486-linuxaout/lib/libdb.so.1
>
> when I remove the glibc libdb in /lib/libdb.so.2 I get:
>
> [root@hammer sendmail]# ldd sendmail
> libdb.so.2 => /usr/i486-linux-libc5/lib/libdb.so.2 (0x40002000)
> libc.so.5 => /lib/libc.so.5 (0x4000f000)
>
> but in both cases the sendmail binary _works_. When I remove the libc5
> libdb
> in /usr/i486-linux-libc5/lib/libdb.so.2 then it crashes with core dump
> in
> strncmp but the ldd output is the same as with both libs installed!
>
The sendmail binary worked because it found the libraries it needed, until
you removed the libdb.so.2 the /usr/....
Did you do a ldconfig after removing the libs. Be aware that ldconfig
update a cache file of shared libraries.
karl.
------------------------------
From: "Ted Pavlic" <[EMAIL PROTECTED]>
Subject: Re: fork() question
Date: Tue, 17 Aug 1999 11:01:42 -0400
This sort of confusion is why threads are becoming so popular. :)
Granted, there's not a lot of confusion, yet threads (while more complex)
tend to do things a little better than forks in what they can or cannot use
and how they communicate with all the other threads.
Rob <[EMAIL PROTECTED] (X=y)> wrote in message
news:7p90b7$584$[EMAIL PROTECTED]...
> Hi, When I do a fork() like this code :
>
> pid = fork()
>
> if (pid==0) // Child process
> {
> some_routine(intparam, charptr);
> exit(0);
> }
>
> // rest of parent process...
>
> and the parent does a waitpid(...) to make sure the child doesn't
> become a zombie.
> Now, my question is, what exactly is copied from the parent to the
> child process? I know file handles are copied to the child, but are
> all global/local variables copied as well ? And what about pointers
> pointing to allocated memory prior to the fork process, can a child
> access this memory as well ?
> Does the above code work then ? I mean the params passed to the
> function are those valid ?
>
> Thanks,
> Rob
>
>
>
>
------------------------------
From: Peter Pointner <[EMAIL PROTECTED]>
Subject: Re: Problems installing Interrupt handler
Date: Tue, 17 Aug 1999 09:41:10 GMT
Joachim Blum <[EMAIL PROTECTED]> wrote:
> Hi,
> I have some problems installing an interrupt handler for a new device.
> I gues I missed something in the documentation, but I really can't see
> it.
> Maybe somebody can help me. Thanks in advance.
> In my device driver, which was able to poll the device I wanted to
> insert the
> interrupt handler. So I did the following steps:
> 1) I wrote the following function:
> static void psm_intr(int irq, void *dev_id, struct pt_regs *regs)
> {
> /* printk("PSM: INTERRUPT !!\n");*/
> return;
> }
> 2) I inserted the following statement in the function init_module()
> if (request_irq(psm_local.irq, psm_intr, 0, "psm", NULL)) {
> printk("PSM: Can't allocate IRQ %d for device\n",psm_local.irq);
> return -EIO;
> }
> This seems to work since the /proc/interrupts show now that IRQ 10 is
> handled
> by my device "PSM"
> But as soon as the device initiates an interrupt the system hangs.
> When I'm removing the lines in init_module() and initiate the interrupt
> the there just no effect (so I guess the device itself is OK).
I think your problem is that nothing clears the hardware interrupt.
Probably your interrupt handler is called in an endless loop. It has to
do something with the hardware, so the interrupt goes away. If you don't
"request_irq", then the interrupt is masked, so no effect.
Peter
------------------------------
From: "Bill Burris" <[EMAIL PROTECTED]>
Subject: Re: threads
Date: Tue, 17 Aug 1999 09:56:53 -0600
Sami Tikka <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> On Fri, 13 Aug 1999 11:58:57 -0600, Bill Burris <[EMAIL PROTECTED]>
wrote:
> >On Windows, muti-threading has become an important tool for me because of
> >the real-time and I/O intensive nature of my applications.
>
> Hmm... does a real-time and i/o-intensive application imply that it should
> be built using threads? I don't follow.
I have multiple devices which I need to respond to regularly. Instead of
going around polling them I have a thread dedicated to servicing each
device. When there is no I/O happening the thread sleeps.
>
> Perhaps that is the case in Windows where, as I understand, co-operating
> processes are very difficult to do.
>
To do this with separate processes means you have the extra overhead
associated with maintaining separate address spaces. There is also the
overhead associated with synchronization and communications between
processes. Threads are essentially a light weight form of multitasking.
This is most likely why NT & IIS was able to serve up web pages more quickly
then Linux & Apache in recent tests. My guess is that Windows programmers
tend to think in terms of threads and Unix programmers tend to think in
terms of processes. Possibly one reason why Linux is more stable, threads
can be difficult to debug.
Bill
--
http://www.icrossroads.com/~spider
------------------------------
From: Bjorn Reese <[EMAIL PROTECTED]>
Crossposted-To: comp.os.linux.development.apps,comp.os.linux.misc
Subject: Re: why not C++?
Date: Tue, 17 Aug 1999 16:42:41 +0000
Kaz Kylheku wrote:
> But there are disadvantages to C++ constructors. For one thing, they do not
> return a value. The only sanctioned mechanism for indicating construction
> failure is to throw an exception. Exception handling requires run-time support
> and causes an increase in object file size. It has only recently begun to be
To add salt to injury, you cannot use exceptions in global static objects
because their constructors are executed before main(), and therefore
cannot catch the exception.
Furthermore, using virtual functions in constructors/destructors can
result in member functions being executed on uninitialized objects.
I've also found it more difficult to debug C++ than C (especially the
code of other people,) because (operator) overloading can make otherwise
innocent looking code do much more than you had expected.
Another poster replied to the above quote, but saying that it can be
managed by the Factory pattern. I agree, and want to add that the
Factory pattern can be implemented in C too.
------------------------------
From: [EMAIL PROTECTED] (Chris)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: Printing in Linux
Date: Tue, 17 Aug 1999 17:35:21 GMT
On 16 Aug 1999 21:02:04 GMT, "Norm Dresner" <[EMAIL PROTECTED]> wrote
in comp.os.linux.development.apps:
>I need to write a c-program to print to the "default" printer which is
Ignore the hardware-- you'll just get yourself into trouble. The system
has a print queue that will manage the printing for you. Just open a pipe
to the lp program and dump everything there.
#include <stdio.h>
FILE *printer;
int error_value;
if((printer = popen("lp", "w") !=NULL) {
fprintf(printer, "Hello, world!\n");
if((error_value = pclose(printer) == -1)
printf("Unable to print: error value is %d\n", errno);
} else
printf("Unable to open printer: error value is %d\n", errno);
>From the popen() man page:
Failure to execute the shell is indistinguishable from the
shell's failure to execute command, or an immediate exit
of the command. The only hint is an exit status of 127.
------------------------------
From: [EMAIL PROTECTED] (Bill M. Catambay)
Crossposted-To: comp.os.linux.development.apps
Subject: [Req] Pascal tools/source/info related to Linux
Date: Tue, 17 Aug 1999 10:33:23 -0700
Greetings all,
I would like to incorporate the Linux world into Pascal Central. In order
to do so, I need to start collecting information such as:
- Pascal tools for Linux (compilers, editors, etc.)
- Pascal source code for Linux (full projects, snippets, etc.)
- Pascal information for Linux (articles, books, etc.)
If you have anything to contribute, I encourage you to contact me. Help
me expand Linux throughout the Pascal community. You can contact me at
[EMAIL PROTECTED]
Cheers,
Bill
----
Bill Catambay, Software Developer, Webmaster
Pascal Central -> http://pascal-central.com
Morgana's Revenge -> http://www.excaliburworld.com/morgana
------------------------------
From: [EMAIL PROTECTED] (Bob Tennent)
Crossposted-To: comp.os.linux.development.apps
Subject: Re: [Req] Pascal tools/source/info related to Linux
Date: 17 Aug 1999 18:21:31 GMT
Reply-To: rdt(a)cs.queensu.ca
On Tue, 17 Aug 1999 10:33:23 -0700, Bill M. Catambay wrote:
>
>I would like to incorporate the Linux world into Pascal Central. In order
>to do so, I need to start collecting information such as:
>
>- Pascal tools for Linux (compilers, editors, etc.)
>- Pascal source code for Linux (full projects, snippets, etc.)
>- Pascal information for Linux (articles, books, etc.)
>
http://tfdec1.fys.kuleuven.ac.be/~michael/fpc/
http://tfdec1.fys.kuleuven.ac.be/~michael/fpc-linux/
http://home.pages.de/~GNU-Pascal
http://agnes.dida.physik.uni-essen.de/~gnu-pascal/misc.html
http://www.rpi.edu/~payned/xwpe/
http://www.rpi.edu/~payned/xwpe/extrasyntax.html
Bob T.
------------------------------
From: [EMAIL PROTECTED] (brian moore)
Crossposted-To: comp.os.linux.security,comp.os.linux.development.apps
Subject: Re: Code for security: chroot and child processes
Date: 17 Aug 1999 18:35:26 GMT
On 12 Aug 1999 02:01:12 GMT,
Mike Khalili <[EMAIL PROTECTED]> wrote:
> On Wed, 11 Aug 1999 16:59:14 -0700, Sean O'Dell <[EMAIL PROTECTED]> wrote:
> >Thank you for your help! It works great, but now I've run into something
> >else I'm not sure about. When the program is run, I use seteuid to change
> >the uid of the process to the uid of the owner of the file interpreted by
> >the program, for security reasons. I also chroot to the user's home
> >directory, just for further safety. However, there are some functions to
> >the program which I need to seteuid back to root and also see the file
> >system hierarchy above where I chroot'ed (just temporarily). I haven't
> >figured out how to "undo" the chroot...is it possible?
>
> No, it is not. Once you chroot() you're stuck with it.
Not entirely true. There are ways to get out of a chroot jail.
--
Brian Moore | Of course vi is God's editor.
Sysadmin, C/Perl Hacker | If He used Emacs, He'd still be waiting
Usenet Vandal | for it to load on the seventh day.
Netscum, Bane of Elves.
------------------------------
From: [EMAIL PROTECTED] (James Stevenson)
Crossposted-To: gnu.gcc.help
Subject: Re: Deadly optimization bug (all versions!)
Reply-To: [EMAIL PROTECTED]
Date: Tue, 17 Aug 1999 12:46:09 +0000
Hi
if you mean compile it like
gcc bug.c -O1
gcc bug.c -O2
it worked fine on my system both
RH6.0
gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
output both compiles
ret=0
ret=1
ret=1
cya
James
On Tue, 17 Aug 1999 08:07:01 GMT, Alex Vinokur <[EMAIL PROTECTED]> wrote:
>In article <7p8scr$krk$[EMAIL PROTECTED]>,
> Veksler Michael <[EMAIL PROTECTED]> wrote:
>>
>>
>> The bug shows itself on gcc-2.7.2.1, egcs-1.0.1, egcs-1.1.2, gcc-2.95.
>> On AIX-4.1, Linux-x86 (RH4.2 and RH6.0).
>>
>> Just try to compile the following code once with -O and once without.
>> This may be the reason behind some of the problems with Linux-2.2.xx
>>
>> (I post this here, instead of gnu.gcc.bugs, since my previous
>> posts did not reach the group).
>>
>> The code:
>>
>> ---------- bug.c --------
>>
>> #include <stdio.h>
>>
>> /* If one=1, then the output should be: bit&1 */
>> unsigned test(unsigned one , unsigned bit)
>> {
>> unsigned val= bit & 1;
>> unsigned zero= one >> 1;
>>
>> val++;
> printf (""); // It is an unnecessary line.
> // All optimzation options work OK with this line.
> //-------------------------------------------------
> // Optimzation options -O1 and -O2 produce
> // invalid results without this line
> //-------------------------------------------------
> // egcs-2.91.57 19980901 (egcs-1.1 release)
> // SunOS 5.6
> // So, it seems to be a compiler bug.
> //-------------------------------------------------
>
>> return zero + ( val>> 1 );
>> }
>>
>> int main()
>> {
>> printf("ret=%d\n", test(1,0)); /* should print 0 */
>> printf("ret=%d\n", test(1,1)); /* should print 1 */
>> printf("ret=%d\n", test(1,65535)); /* should print 1 */
>>
>> return 0;
>> }
>>
>>
>
> Alex
>
>
>Sent via Deja.com http://www.deja.com/
>Share what you know. Learn what you don't.
--
=============================================
Check Out: http://www.users.zetnet.co.uk/james/
E-Mail: [EMAIL PROTECTED]
12:40pm up 11:49, 3 users, load average: 2.00, 2.00, 2.00
------------------------------
** 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 (and comp.os.linux.development.system) via:
Internet: [EMAIL PROTECTED]
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-System Digest
******************************