LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-16-2010, 01:23 PM   #1
lipun4u
Member
 
Registered: Sep 2008
Location: Mumbai, india
Distribution: ubuntu and hp-unix
Posts: 118

Rep: Reputation: 15
signal error


#!/bin/sh

trap "echo Haha" SIGUSER1
echo "asit"
count=1
while [ $count -le 10 ]
do
echo "Loop #$count"
sleep 10
count=$[ $count + 1 ]
done
echo "This is the end"

plz check out...why this is showing following error ???
trap: 3: SIGUSER1: bad trap
 
Old 06-16-2010, 01:39 PM   #2
alunduil
Member
 
Registered: Feb 2005
Location: San Antonio, TX
Distribution: Gentoo
Posts: 684

Rep: Reputation: 62
The second argument to trap needs to be an executable that will be executed on logout. Perhaps, the following will work: `trap $(echo Haha) SIGUSER1.

Regards,

Alunduil
 
Old 06-16-2010, 02:05 PM   #3
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
You can't trap multi-token simple commands. You need to encapsulate them inside functions like:

Code:
haha() {
    echo Haha
}

trap haha SIGUSER1
...

Last edited by konsolebox; 06-16-2010 at 02:07 PM.
 
Old 06-17-2010, 02:15 PM   #4
lipun4u
Member
 
Registered: Sep 2008
Location: Mumbai, india
Distribution: ubuntu and hp-unix
Posts: 118

Original Poster
Rep: Reputation: 15
does unix and linux vary in the way they handle signal ???
 
Old 06-20-2010, 10:01 PM   #5
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
Quote:
Originally Posted by lipun4u View Post
does unix and linux vary in the way they handle signal ???
Inter-process communication (IPC) of Linux was based from UNIX (read "The Design of the UNIX Operating System" which Linux was based) so probably it's the same although I'm still not certain. Still it's best to just try it with other systems anyway.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
man error (grof grotty error signal 11) SW-ANIKY Linux - Newbie 1 12-21-2007 11:10 AM
Signal 11 error dialogs linus321 Linux - Software 5 05-28-2005 07:24 AM
there is an error when i use signal() in c++ icoming Programming 7 05-30-2004 10:33 AM
Signal 6: Unknown Signal <=> Error with MAYA4.X under Linux SOLVED!!!! Faeroon Linux - Software 9 05-09-2003 01:57 PM
Signal 11 error Rocky Linux - Newbie 1 10-24-2001 07:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:30 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration