Re: basic signal problem
From: amsa (amsavarthini_at_yahoo.com)
Date: 08/24/04
- Next message: Pascal Bourguignon: "Re: A userland implementation of a good filesystem in a file"
- Previous message: G. S. Hayes: "Re: Problem with a program coming from Windows"
- In reply to: Kurtis D. Rader: "Re: basic signal problem"
- Next in thread: Kurtis D. Rader: "Re: basic signal problem"
- Reply: Kurtis D. Rader: "Re: basic signal problem"
- Reply: Barry Margolin: "Re: basic signal problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 23 Aug 2004 21:35:59 -0700
Hi All,
Thanks for all your help. But I Dont understand one thing in signals.
Signals, like pipes and FIFO's are also used for communication of data
within processes. But learning signals, i feel it is more of error
handling b/w the process-kernel. How is this used for communication
b/w 2 processes (forget the 'kill' system call) ?
'kill' system call is used for communication b/w 2 processes...but why
the name 'kill'...it doesnt represent a meaningful name (i am just
curious abt this system call).
amsa.
"Kurtis D. Rader" <krader@skepticism.us> wrote in message news:<pan.2004.08.22.15.39.55.778962@skepticism.us>...
> On Sun, 22 Aug 2004 02:44:31 -0700, amsa wrote:
>
> > main()
> > {
> > int i=0,j=50;
> > signal(SIGILL, sigkey)
> > j=j/i;
> > }
> >
> > void sigkey(signo)
> > int signo
> > {
> > printf("\n process recieved signal :%d",signo); exit(0);
> > }
> >
> > here actually SIGILL (illegal instruction code) should be passed from
> > the kernel 'cause of DIVIDE-BY-ZERO and such that function sigkey should
> > be called. but that doesnt happen...it gives the output "Floating Point
> > Exception".
>
> Why would you expect SIGILL. Assuming your compiler isn't broken your
> program won't contain an illegal opcode (i.e., machine instruction). There
> isn't a signal for invalid mathematical operations involving integers.
> Instead the kernel uses SIGFPE (floating point exception) for invalid
> operations that involve either floating point or integer operands.
>
> > my 2nd problem:
> >
> > main()
> > {
> > int fd;
> > signal(SIGSYS,abc);
> > fd=open("somefile",O_RDONLY);
> > lseek(fd,0,5);
> > }
> > }
> > void abc()
> > {
> > printf("\n illegal use of system call\n"); exit(0);
> > }
> > }
> > here the function abc should be called, because lseek cannot have 5 as
> > the 3rd parameter. so signal SIGSYS should be passed... but nothing
> > happens...why.
>
> Your man page probably says something like "bad argument to routine" as
> the reason for SIGSYS. But I've never seen a UNIX implementation which
> does that. All the ones I've ever worked with raise SIGSYS only for the
> case where it doesn't recognize the system call being made by the process.
> Invalid arguments will result in a return code of -1 with errno set to
> EINVAL or EFAULT for most syscalls (there are exceptions to this rule so
> read the documentation for the syscall you're concerned about).
- Next message: Pascal Bourguignon: "Re: A userland implementation of a good filesystem in a file"
- Previous message: G. S. Hayes: "Re: Problem with a program coming from Windows"
- In reply to: Kurtis D. Rader: "Re: basic signal problem"
- Next in thread: Kurtis D. Rader: "Re: basic signal problem"
- Reply: Kurtis D. Rader: "Re: basic signal problem"
- Reply: Barry Margolin: "Re: basic signal problem"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|