Linux-Development-Apps Digest #399, Volume #7    Mon, 14 May 01 09:13:15 EDT

Contents:
  Re: How do I kill a task that does not want to get removed from ps x with kill? 
(Rolf Magnus)
  Re: transpareny (Kasper Dupont)
  Re: transpareny ("Nils O. Selåsdal")
  Timer function ? ("Peet Grobler")
  Re: Timer function ? (Chris)
  Memory leak debug ("Moshe Shimoni")
  Stack trace - Multi threaded ("Moshe Shimoni")
  Re: find size of available memory? (Lew Pitcher)
  Re: Memory leak debug (Rolf Magnus)
  Re: abort() doesn't generate a core dump? (Rolf Magnus)
  Re: Memory leak debug (Mathias Waack)
  Re: find size of available memory? (Ulrich Lauther)
  Re: Public Domain CODEC ("Lewis Fraga")
  Re: Public Domain CODEC ("Lewis Fraga")
  Re: Stack trace - Multi threaded (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)
  Re: Public Domain CODEC (Rolf Magnus)
  Re: Public Domain CODEC (Rolf Magnus)
  Re: How do I kill a task that does not want to get removed from ps x  (Josef 
Moellers)

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

From: Rolf Magnus <[EMAIL PROTECTED]>
Subject: Re: How do I kill a task that does not want to get removed from ps x with 
kill?
Date: Mon, 14 May 2001 09:46:51 +0200

Jan Panteltje wrote:

> Sometimes a process (program that connects to /dev/video) crashes.
> But then I need to reboot to get rid of it.
> I need to get rid of it to be able to use /dev/video again.
> fuser /dev/video shows it is still in use.
> ANY signal in kill or skill does NOT work to remove this program from the
> ps x, neitehr does killall programname.
> 
> Is there perhaps ANY other way to remove a task from the kernel scheduler,
> regardless of its state?

If kill -9 doesn't work, your video driver itself may have crashed. I had 
this some time with a buggy driver for my sound card. The process accessing 
it crashed and could not be killed.

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

From: Kasper Dupont <[EMAIL PROTECTED]>
Crossposted-To: 
alt.linux,comp.os.linux.development.system,linux.redhat.devel,linux.redhat.development
Subject: Re: transpareny
Date: Mon, 14 May 2001 08:15:48 +0000

Darren LS wrote:
> 
> Kasper Dupont <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> > Darren LS wrote:
> > >
> > > hi all I have a lovely little socket program that talks to a server
> > > blahdebla
> > > sadly when I run it it steals all the runtime of the tty node, I can run
> it
> > > in the background with the suffix of the & character but I would rather
> it
> > > run in the background automatically. does anyone know if this is
> possible?
> > > either via the system or programmatically?
> > >
> > > Thank you
> >
> > If you are writing a C program this is probably
> > what you want:
> >
> > if (fork()) exit(0);
> >
> > Or if you want to check for errors as well:
> >
> > switch(fork()) {
> >  case 0: break;
> >  case -1: perror("fork"); exit(1);
> >  default: exit(0);
> > }
> >
> 
> Hi Kasper.
> 
> how would I incorporate this in my programme? would it be the first part of
> the main function or would I have to stick mymain code in a function?
> Thanks Kasper
> 
> Darren

In most situations using it as the first part of
main() will work as expected. If you prefer you
can also put the code in a function which you call
from the start of the main() function.

-- 
Kasper Dupont

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

From: "Nils O. Selåsdal" <[EMAIL PROTECTED]>
Crossposted-To: 
alt.linux,comp.os.linux.development.system,linux.redhat.devel,linux.redhat.development
Subject: Re: transpareny
Date: Mon, 14 May 2001 10:42:14 +0200


"Darren LS" <[EMAIL PROTECTED]> wrote in message
news:dBDL6.3906$[EMAIL PROTECTED]...
>
> Kasper Dupont <[EMAIL PROTECTED]> wrote in message
> news:[EMAIL PROTECTED]...
> > Darren LS wrote:
> > >
> > > hi all I have a lovely little socket program that talks to a server
> > > blahdebla
> > > sadly when I run it it steals all the runtime of the tty node, I can
run
> it
> > > in the background with the suffix of the & character but I would
rather
> it
> > > run in the background automatically. does anyone know if this is
> possible?
> > > either via the system or programmatically?
> > >
> > > Thank you
> >
> > If you are writing a C program this is probably
> > what you want:
> >
> > if (fork()) exit(0);
> >
> > Or if you want to check for errors as well:
> >
> > switch(fork()) {
> >  case 0: break;
> >  case -1: perror("fork"); exit(1);
> >  default: exit(0);
> > }
> >
>
> Hi Kasper.
>
> how would I incorporate this in my programme? would it be the first part
of
> the main function or would I have to stick mymain code in a function?
> Thanks Kasper
put it when your program is ready to to what its supposed to, that is after
its
parsed and checked the commandline arguments,(if any) and found no error.




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

From: "Peet Grobler" <[EMAIL PROTECTED]>
Subject: Timer function ?
Date: Mon, 14 May 2001 12:39:05 +0200

I need to know if the following function exists in Linux, or if it can
somehow be implemented:

My program should call a function to set a timer. Arguments include a
sequence number (int), and a function to call if timer expires.

It should also be able to "unset" the timer, e.g. delete the timer.

If the timer expires, it should call the function parsed to the initial set
function, with the relevant sequence number.

Something like sleep won't work, since the program should continue
processing while it's waiting for the timer. I cannot fork() a new process
for situation requiring a timer, since it'll slow down the system too much.

Any comments?



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

From: Chris <[EMAIL PROTECTED]>
Subject: Re: Timer function ?
Date: Mon, 14 May 2001 12:06:21 +0100

Peet Grobler wrote:
> 
> I need to know if the following function exists in Linux, or if it can
> somehow be implemented:
> 
> My program should call a function to set a timer. Arguments include a
> sequence number (int), and a function to call if timer expires.
> 
> It should also be able to "unset" the timer, e.g. delete the timer.
> 
> If the timer expires, it should call the function parsed to the initial set
> function, with the relevant sequence number.
> 
> Something like sleep won't work, since the program should continue
> processing while it's waiting for the timer. I cannot fork() a new process
> for situation requiring a timer, since it'll slow down the system too much.
> 
> Any comments?

You can use alarm(2), setitimer(2) etc., and set signal
handlers to deal with the resulting signals (and beware
of race conditions, and interrupted system calls and so
forth). Note that this will deliver notification
asynchronously, which may not be what you want; also, you
can only have one alarm clock active at a time, and you
can't associate arbitrary data with the notification.

Alternatively, if your program consists of a big select(2)
loop, you could just compare the time now with the
deadline for your timer, setting the timeout in select
accordingly, and then act when the deadline expires. Or
you could set a flag in the alarm signal handler, rely on
this to interrupt the select call, and then act on the
flag.

Or, you could sleep in a thread, which is certainly much
less overhead than forking, but pretty ugly. Of course,
you then have to get notification back to your main
process, presumably via a shared variable with appropriate
concurrency control.

-- 
Chris Lightfoot -- chris at ex dash parrot dot com -- www.ex-parrot.com/~chris/
 ``I'd rather listen to Newton than to Mundie. He may have been dead for almost
   three hundred years, but despite that he stinks up the room less.''
   (Linux Torvalds on Microsoft executive Craig Mundie)

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

From: "Moshe Shimoni" <[EMAIL PROTECTED]>
Subject: Memory leak debug
Date: Mon, 14 May 2001 14:16:13 +0200

Hello,
I need a tool to find memory leaks on a multi threaded linux application. I
prefer a tool which does not force me to recompile my app. I would even
prefer not to relink my o-files. There is a tool memprof which does not
support threads. I can't install to my RedHat 6.2 linux i686 KDE the new
version(4.0), so I'm stuck.
What should I do?



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

From: "Moshe Shimoni" <[EMAIL PROTECTED]>
Subject: Stack trace - Multi threaded
Date: Mon, 14 May 2001 14:18:14 +0200

Hello,
I need to trace my stack on a multi threaded app. I tried using
'g_on_error_stack_trace' but it freezes my computer.
What should I do?



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

From: [EMAIL PROTECTED] (Lew Pitcher)
Subject: Re: find size of available memory?
Reply-To: [EMAIL PROTECTED]
Date: Mon, 14 May 2001 11:50:31 GMT

On Sun, 13 May 2001 15:37:10 +0000, Chris <[EMAIL PROTECTED]> wrote:

>Ulrich Lauther wrote:
>> 
>> I need to implement an algorithm whose speed depends on the size of
>> buffers I allocate, so I want to allocate a lot.
>> On the other hand, I do not want to make the computer swap.
>> So, how can I find out the size of malloc-able memory without swapping?
>
>Parse /proc/meminfo.

and hope your system load doesn't change



Lew Pitcher
IT Consultant, Development Services
Toronto Dominion Bank Financial Group

(Opinions expressed are my own, not my employers')

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

From: Rolf Magnus <[EMAIL PROTECTED]>
Subject: Re: Memory leak debug
Date: Mon, 14 May 2001 13:49:31 +0200

Moshe Shimoni wrote:

> Hello,
> I need a tool to find memory leaks on a multi threaded linux application.
> I prefer a tool which does not force me to recompile my app. I would even
> prefer not to relink my o-files. There is a tool memprof which does not
> support threads. I can't install to my RedHat 6.2 linux i686 KDE the new
> version(4.0), so I'm stuck.
> What should I do?

What about the mtrace() function in glibc?

info "(libc)Allocation Debugging"
info "(libc)Hooks for Malloc"

should help.

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

From: Rolf Magnus <[EMAIL PROTECTED]>
Subject: Re: abort() doesn't generate a core dump?
Date: Mon, 14 May 2001 14:01:45 +0200

Kaz Kylheku wrote:

> On 11 May 2001 06:54:49 GMT, Villy Kruse
> <[EMAIL PROTECTED]> wrote:
>>On 11 May 2001 08:19:39 +0200, Måns Rullgård <[EMAIL PROTECTED]>
>>wrote:
>>
>>>
>>>Also in Linux multithreaded programs do not generate core dumps. Read
>>>kernel mailing list archives to find out why.
>>>
>>
>>Also suid programs don't produce core dumps for security reasons.
> 
> Also certain fatal signals don't produce core, like SIGBUS.

But abort() doesn't generate SIGBUS.

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

From: Mathias Waack <[EMAIL PROTECTED]>
Subject: Re: Memory leak debug
Date: Mon, 14 May 2001 14:04:01 +0200

Moshe Shimoni wrote:
> I need a tool to find memory leaks on a multi threaded linux application.
> I prefer a tool which does not force me to recompile my app. I would even
> prefer not to relink my o-files. There is a tool memprof which does not
> support threads. I can't install to my RedHat 6.2 linux i686 KDE the new
> version(4.0), so I'm stuck.
> What should I do?

Try other tools like memprof, for instance LeakTracer, ccmalloc, dmalloc, 
njamd and yamd do this job and some of them are thread safe. 

Mathias

-- 
Mathias Waack           |     [EMAIL PROTECTED]
Tel.:  +49 621 181 2717  Fax.:  +49 621 181 2713

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

From: Ulrich Lauther <[EMAIL PROTECTED]>
Subject: Re: find size of available memory?
Date: 14 May 2001 12:06:11 GMT
Reply-To: [EMAIL PROTECTED]

Chris <[EMAIL PROTECTED]> wrote:
: Ulrich Lauther wrote:
: > 
: > I need to implement an algorithm whose speed depends on the size of
: > buffers I allocate, so I want to allocate a lot.
: > On the other hand, I do not want to make the computer swap.
: > So, how can I find out the size of malloc-able memory without swapping?

: Parse /proc/meminfo.

and what number do I go for?
        total:    used:    free:  shared: buffers:  cached:
        Mem:  397131776 374337536 22794240 134352896 31215616 220061696
        Swap: 419479552 17829888 401649664
        MemTotal:    387824 kB
        MemFree:      22260 kB
        MemShared:   131204 kB
        Buffers:      30484 kB
        Cached:      214904 kB
        SwapTotal:   409648 kB
        SwapFree:    392236 kB

The "free" memory is very small, as the kernel grabs whatever is available.
So it's not obvious how much *I* can grab without doing harm.

-- 
        -lauther

[nosave]
============================================================================
Ulrich Lauther          ph: +49 89 636 48834 fx: ... 636 42284
Siemens CT SE 6         Internet: [EMAIL PROTECTED]

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

From: "Lewis Fraga" <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.apps,misc.writing.screenplays,alt.movies.independent
Subject: Re: Public Domain CODEC
Date: Mon, 14 May 2001 12:37:26 GMT


Matrixx Entertainment <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> I'm coming to these two Linux groups (hopefully the appropriate ones) as
an
> independent producer/director in the motion picture industry seeking
advice
> and promulgating a need.
>
> After about three years of, often acrimonious, debate on the
Hollywood-based
> U.S. motion picture industry and reform thereof (see
> http://www.homevideo.net/FIRM), several suggestions have emerged in
> connection with the possibility of creating an alternative network of
> DISTRIBUTION of motion pictures over the Internet, such involving the
> possible development of a PUBLIC DOMAIN CODEC that would be compatible
with
> both TCP/IP file transfers over the Internet as well as analog/digital
cable
> modem transfers over same.  We are specifically talking about DOWNLOADING
> movies . . . NOT *streaming* them at this time.
>
> For those of you who are not familiar with the motion picture industry or
> why such a PUBLIC DOMAIN CODEC may be desirable, here's a quick cram
course:
>

  First of all, I don't know which group you thought you clicked on, but
this is the movies.independent NG - so, yes, we know how the motion picture
industry works.
  Second, there is one format emerging big time, if you keep up with
trechnology instead of spatting everything you don't know about society.
It's called DivX, or MPEG4 - you can download entire movies into your hard
drive and save them onto one CD-R at VHS quality. That's reight - 650 megs
holds an entire movie that you can play on any DVD player that also plays
VideoCD format.

-Lew




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

From: "Lewis Fraga" <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.apps,misc.writing.screenplays,alt.movies.independent
Subject: Re: Public Domain CODEC
Date: Mon, 14 May 2001 12:37:26 GMT


Matrixx Entertainment <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]...
> I'm coming to these two Linux groups (hopefully the appropriate ones) as
an
> independent producer/director in the motion picture industry seeking
advice
> and promulgating a need.
>
> After about three years of, often acrimonious, debate on the
Hollywood-based
> U.S. motion picture industry and reform thereof (see
> http://www.homevideo.net/FIRM), several suggestions have emerged in
> connection with the possibility of creating an alternative network of
> DISTRIBUTION of motion pictures over the Internet, such involving the
> possible development of a PUBLIC DOMAIN CODEC that would be compatible
with
> both TCP/IP file transfers over the Internet as well as analog/digital
cable
> modem transfers over same.  We are specifically talking about DOWNLOADING
> movies . . . NOT *streaming* them at this time.
>
> For those of you who are not familiar with the motion picture industry or
> why such a PUBLIC DOMAIN CODEC may be desirable, here's a quick cram
course:
>

  First of all, I don't know which group you thought you clicked on, but
this is the movies.independent NG - so, yes, we know how the motion picture
industry works.
  Second, there is one format emerging big time, if you keep up with
trechnology instead of spatting everything you don't know about society.
It's called DivX, or MPEG4 - you can download entire movies into your hard
drive and save them onto one CD-R at VHS quality. That's reight - 650 megs
holds an entire movie that you can play on any DVD player that also plays
VideoCD format.

-Lew




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

From: [EMAIL PROTECTED] (=?iso-8859-1?q?M=E5ns_Rullg=E5rd?=)
Subject: Re: Stack trace - Multi threaded
Date: 14 May 2001 14:47:22 +0200

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

> Hello,
> I need to trace my stack on a multi threaded app. I tried using
> 'g_on_error_stack_trace' but it freezes my computer.
> What should I do?
> 
> 

You can install a signal handler for SIGSEGV or whatever is causing
problems and use the 'backtrace' function. Look in execinfo.h. This
will produce a stacktrace. You could also have the signal handler
sleep for ever so you can attach gdb to the process. For some reason
some threaded programs will not run if started from gdb.

-- 
Måns Rullgård
[EMAIL PROTECTED]

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

From: Rolf Magnus <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.apps,misc.writing.screenplays,alt.movies.independent
Subject: Re: Public Domain CODEC
Date: Mon, 14 May 2001 15:01:08 +0200

Lewis Fraga wrote:

>   Second, there is one format emerging big time, if you keep up with
> trechnology instead of spatting everything you don't know about society.
> It's called DivX, or MPEG4

Wrong. DivX is a hacked version of a derivate of MPEG4.

> - you can download entire movies into your hard
> drive and save them onto one CD-R at VHS quality. That's reight - 650 megs
> holds an entire movie that you can play on any DVD player that also plays
> VideoCD format.

Wrong. I don't know any DVD player that can play DivX.

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

From: Rolf Magnus <[EMAIL PROTECTED]>
Crossposted-To: 
comp.os.linux.development.apps,misc.writing.screenplays,alt.movies.independent
Subject: Re: Public Domain CODEC
Date: Mon, 14 May 2001 15:01:08 +0200

Lewis Fraga wrote:

>   Second, there is one format emerging big time, if you keep up with
> trechnology instead of spatting everything you don't know about society.
> It's called DivX, or MPEG4

Wrong. DivX is a hacked version of a derivate of MPEG4.

> - you can download entire movies into your hard
> drive and save them onto one CD-R at VHS quality. That's reight - 650 megs
> holds an entire movie that you can play on any DVD player that also plays
> VideoCD format.

Wrong. I don't know any DVD player that can play DivX.

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

From: Josef Moellers <[EMAIL PROTECTED]>
Subject: Re: How do I kill a task that does not want to get removed from ps x 
Date: Mon, 14 May 2001 15:05:33 +0200

Rolf Magnus wrote:
> =

> Jan Panteltje wrote:
> =

> > Sometimes a process (program that connects to /dev/video) crashes.
> > But then I need to reboot to get rid of it.
> > I need to get rid of it to be able to use /dev/video again.
> > fuser /dev/video shows it is still in use.
> > ANY signal in kill or skill does NOT work to remove this program from=
 the
> > ps x, neitehr does killall programname.
> >
> > Is there perhaps ANY other way to remove a task from the kernel sched=
uler,
> > regardless of its state?
> =

> If kill -9 doesn't work, your video driver itself may have crashed. I h=
ad
> this some time with a buggy driver for my sound card. The process acces=
sing
> it crashed and could not be killed.

This is not entirely true:

Whenever a process waits for an event, it "goes to sleep". When the
event occurs (most probably within another context), the sleeping
process is "woken up", scheduled and run, as soon as there is a CPU
available.

Also, a process will be woken up when a signal is sent to it (which it
has chosen not to ignore). The awakening process has to check the return
value from sleep() (the kernel function!) to see whether the event has
occurred or a signal has been delivered. In the latter case, the event
the process was waiting for will most likeley not have occurred, so
special care must be taken to handle this case. However, sometimes this
is too complicated or cannot be done because e.g. the cleanup would be
another kernel component's responsibility. In that case, a process will
go to sleep and specify that it should not be awoken when a signal is
delivered, even when it's a SIGKILL.
Usually some timeout mechanism will guarantee that the event occurs some
way or the other. If it doesn't, the process hangs and cannot be killed.

It may very well be that some hardware (which should generate an
interrupt at some time) does not do this, or some programming error
prevents the wakeup() from being called, so the driver does not have to
crash in order to keep a process permanently sleeping.
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
        If failure had no penalty success would not be a prize
                                                -- T.  Pratchett

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


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