Sponsored Content
Top Forums Shell Programming and Scripting hi all please help me in this issue. Post 302340712 by bhas85 on Tuesday 4th of August 2009 09:07:10 AM
Old 08-04-2009
hi john

Its working .Thank you very much for ur valuable reply.
Regards,
Vijay

---------- Post updated at 08:07 AM ---------- Previous update was at 08:05 AM ----------

Quote:
Originally Posted by johnbach
Code:
while [ 1 ]
do
   #run your process in background 
   process argument &
   wait $!
   sleep 1
echo 'Restarting'
done


Hi,
Slight modification in my requirement, I want in the code that if the process is killed or aborted when the process is running, It should restart at that time also.
The signals are as below:

switch(signum){
case SIGHUP: return "JVM hangup";
break;
case SIGINT: return "JVM interrupted";
break;
case SIGQUIT: return "JVM Quit";
break;
case SIGILL: return "Illegal instruction";
break;
case SIGABRT: return "JVM aborted";
break;
case SIGFPE: return "Floating point exception";
break;
case SIGKILL: return "JVM killed";
break;
case SIGBUS: return "Bus error";
break;
case SIGSEGV: return "Segmentation violation";
break;
case SIGSYS: return "Bad argument to system call";
break;
case SIGTERM: return "Software termination signal from kill";
break;
case SIGCHLD: return "Child process terminated or stopped";
break;
default: return "JVM abnormally terminated";
break;
}
I dont know how to trap these signals in the script.
Please let me solve in this issue.

Thanks in advance.
Vijay,

Last edited by bhas85; 08-04-2009 at 10:12 AM..
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

ps issue

HI All, Suddenly don't know what happened to redhat linux 7.2 any program start then itsn't listing while using ps -ef ex: ./xyz this xyz program pid not showing in ps-ef Pls let me know what is the reason for the same. Thanks a lot in advance Bache (7 Replies)
Discussion started by: bache_gowda
7 Replies

2. Shell Programming and Scripting

Unix Arithmatic operation issue , datatype issue

Hi, I have a shell scripting. This will take 7 digit number in each line and add 7 digit number with next subsequent lines ( normal addition ). Eg: 0000001 0000220 0001235 0000022 0000023 ........... ......... ........ Like this i am having around 1500000 records. After adding... (23 Replies)
Discussion started by: thambi
23 Replies

3. UNIX for Dummies Questions & Answers

ISSUE and ISSUE.NET files

In LINUX(CentOS, RedHat) is there a way to have the banner statement appear before the logon instead of after the logon? In UNIX and Windows the banner appears before a person actually logs on, what I'm seeing in LINUX is that it appears after the login(ftp, telnet, SSH). Thanks (0 Replies)
Discussion started by: ejjones
0 Replies

4. Solaris

IP issue

hi , I have a Solaris server which is part of a domain. The IP for this Solaris box is allocated dyanamically by a DHCP. Everytime the solaris box is restarted the IP gets changed. Being an admin what should i do to find the new ip of the Solaris server sitting at my location? Till now i get... (2 Replies)
Discussion started by: BalajiUthira
2 Replies

5. Shell Programming and Scripting

CP Issue

I want to copy large amount of files aproximately more than 20,000 files from one file system to another file system, but it gives me error like: #cd /opt/appserver/images #cp * /opt/appserver02/public/images Argument list is too long Also above mention error appear again when i run: ... (1 Reply)
Discussion started by: telnor
1 Replies

6. Shell Programming and Scripting

Need assistance with a file issue and a terminal issue

Hello everyone, I'm in need of some assistance. I'm currently enrolled in an introductory UNIX shell programming course and, well halfway through the semester, we are receiving our first actual assignment. I've somewhat realized now that I've fallen behind, and I'm working to get caught up, but for... (1 Reply)
Discussion started by: MrMagoo22
1 Replies

7. Shell Programming and Scripting

Variable value substitution issue with awk command issue

Hi All, I am using the below script which has awk command, but it is not returing the expected result. can some pls help me to correct the command. The below script sample.ksh should give the result if the value of last 4 digits in the variable NM matches with the variable value DAT. The... (7 Replies)
Discussion started by: G.K.K
7 Replies

8. Shell Programming and Scripting

What could be the issue ?

Hi, when i am trying below script assume that below values are taken in code #!/bin/ksh if then echo usage: aNlist.sh QMGR NAME MQREQ fi NL=`echo 'dis qmgr'|runmqsc $1|grep REPOSNL|sed 's/.*REPOSNL\(.*\).*/\1/' |cut -d'(' -f2|cut -d')' -f1` echo 'define nl('$NL_$2')... (25 Replies)
Discussion started by: darling
25 Replies

9. Shell Programming and Scripting

Issue with wc -c and wc -m

Hi All, I have a small queries to get the character count i tried with wc -c and wc -m but its not returend current result For eg: wc -c wc -m echo "Name" | wc -c result: 5 but actually it should returned 4 Help me on this to ge the correct one. Thanks! ----------... (4 Replies)
Discussion started by: siva.pitchai
4 Replies
signal(3)						     Library Functions Manual							 signal(3)

Name
       signal - simplified software signal facilities

Syntax
       #include <signal.h>

       (*signal(sig, func))()
       void (*func)();

Description
       The subroutine is a simplified interface to the more general sigvec(2) facility.

       A  signal  is  generated  by some abnormal event, initiated by a user at a terminal (quit, interrupt, stop), by a program error (bus error,
       etc.), by request of another program (kill), or when a process is stopped because it wishes to access its control  terminal  while  in  the
       background.   For  further information, see Signals are optionally generated when a process resumes after being stopped, when the status of
       child process changes, or when input is ready at the control terminal.  Most signals cause termination  of  the	receiving  process  if	no
       action  is  taken;  some  signals  instead  cause  the process receiving them to be stopped, or are simply discarded if the process has not
       requested otherwise.  Except for the SIGKILL and SIGSTOP signals, the call allows signals either to be ignored or to cause an interrupt	to
       a specified location.  The following is a list of all signals with names as in the include file
       < signal.h >:

       SIGHUP	 1    Hangup
       SIGINT	 2    Interrupt
       SIGQUIT	 3*   Quit
       SIGILL	 4*   Illegal instruction
       SIGTRAP	 5*   Trace trap
       SIGIOT	 6*   IOT instruction
       SIGEMT	 7*   EMT instruction
       SIGFPE	 8*   Floating point exception
       SIGKILL	 9    Kill (cannot be caught or ignored)
       SIGBUS	 10*  Bus error
       SIGSEGV	 11*  Segmentation violation
       SIGSYS	 12*  Bad argument to system call
       SIGPIPE	 13   write on a pipe with no one to read it
       SIGALRM	 14   Alarm clock
       SIGTERM	 15   Software termination signal
       SIGURG	 16o  Urgent condition present on socket
       SIGSTOP	 17+  Stop (cannot be caught or ignored)
       SIGTSTP	 18+  Stop signal generated from keyboard
       SIGCONT	 19o  Continue after stop
       SIGCHLD	 20o  Child status has changed
       SIGTTIN	 21+  Background read attempted from control terminal
       SIGTTOU	 22+  Background write attempted to control terminal
       SIGIO	 23o  I/O is possible on a descriptor (see fcntl(2))
       SIGXCPU	 24   Cpu time limit exceeded (see setrlimit(2))
       SIGXFSZ	 25   File size limit exceeded (see setrlimit(2))
       SIGVTALRM 26   Virtual time alarm (see setitimer(2))
       SIGPROF	 27   Profiling timer alarm (see setitimer(2))
       SIGWINCH  28o  Window size change
       SIGLOST	 29   lock not reclaimed after server recovery
       SIGUSR1	 30   User defined signal
       SIGUSR2	 31   User defined signal
       SIGCLD	      System V name for SIGCHLD
       SIGABRT	      X/OPEN name for SIGIOT

       The starred signals in the list above cause a core image if not caught or ignored.

       If  func  is  SIG_DFL, the default action for signal sig is reinstated; this default is termination (with a core image for starred signals)
       except for signals marked with o or +.  Signals marked with o are discarded if the action is SIG_DFL;  signals  marked  with  +	cause  the
       process to stop.  If func is SIG_IGN the signal is subsequently ignored and pending instances of the signal are discarded.  Otherwise, when
       the signal occurs further occurrences of the signal are automatically blocked and func is called.

       A return from the function unblocks the handled signal and continues the process at the point it was interrupted.  Unlike  previous  signal
       facilities, the handler func remains installed after a signal has been delivered.

       If  a caught signal occurs during certain system calls, causing the call to terminate prematurely, the call is automatically restarted.	In
       particular this can occur during a read or on a slow device (such as a terminal; but not a file) and during a

       The value of is the previous (or initial) value of func for the particular signal.

       After a or the child inherits all signals.  The system call resets all caught  signals  to  the	default  action;  ignored  signals  remain
       ignored.

Environment
       When  your  program  is	compiled  using  the System V environment the handler function does NOT remain installed after the signal has been
       delivered.

       Also, when a signal which is to be caught occurs during a read,	write, or ioctl to a slow device (like a terminal, but	not  a	file);	or
       during  a   pause;  or wait that does not return immediately,  the  signal  handler  function is executed, and then the interrupted  system
       call  may return  a -1 to the calling process with errno set to EINTR.

Notes
       The handler routine can be declared as follows:

	   handler(sig, code, scp)
	   int sig, code;
	   struct sigcontext *scp;

       Here sig is the signal number.  The MIPS hardware exceptions are mapped to specific signals as defined by the table below.   The  parameter
       code is either a constant as given below or zero.  The parameter scp is a pointer to the sigcontext structure (defined in <signal.h>), that
       is the context at the time of the signal and is used to restore the context if the signal handler returns.

       The following defines the mapping of MIPS hardware exceptions to signals and codes.  All of these symbols are defined in either	<signal.h>
       or <mips/cpu.h>:

       Hardware exception			   Signal	Code
       Integer overflow 			   SIGFPE	EXC_OV
       Segmentation violation			   SIGSEGV	SEXC_SEGV
       Illegal Instruction			   SIGILL	EXC_II
       Coprocessor Unusable			   SIGILL	SEXC_CPU
       Data Bus Error				   SIGBUS	EXC_DBE
       Instruction Bus Error			   SIGBUS	EXC_IBE
       Read Address Error			   SIGBUS	EXC_RADE
       Write Address Error			   SIGBUS	EXC_WADE
       User Breakpoint (used by debuggers)	   SIGTRAP	BRK_USERBP
       Kernel Breakpoint (used by prom) 	   SIGTRAP	BRK_KERNELBP
       Taken Branch Delay Emulation		   SIGTRAP	BRK_BD_TAKEN
       Not Taken Branch Delay Emulation 	   SIGTRAP	BRK_BD_NOTTAKEN
       User Single Step (used by debuggers)	   SIGTRAP	BRK_SSTEPBP
       Overflow Check				   SIGTRAP	BRK_OVERFLOW
       Divide by Zero Check			   SIGTRAP	BRK_DIVZERO
       Range Error Check			   SIGTRAP	BRK_RANGE

       When  a	signal	handler  is reached, the program counter in the signal context structure (sc_pc) points at the instruction that caused the
       exception as modified by the branch delay bit in the cause register.  The cause register at the time of the exception is also saved in  the
       sigcontext structure (sc_cause).  If the instruction that caused the exception is at a valid user address it can be retrieved with the fol-
       lowing code sequence:

	   if(scp->sc_cause & CAUSE_BD){
	       branch_instruction = *(unsigned long *)(scp->sc_pc);
	       exception_instruction = *(unsigned long *)(scp->sc_pc + 4);
	   }
	   else
	       exception_instruction = *(unsigned long *)(scp->sc_pc);

       Where CAUSE_BD is defined in <mips/cpu.h>.

       The signal handler may fix the cause of the exception and re-execute the instruction, emulate the instruction and then step over it or per-
       form some non-local goto such as a longjump() or an exit().

       If  corrective action is performed in the signal handler and the instruction that caused the exception would then execute without a further
       exception, the signal handler simply returns and re-executes the instruction (even when the branch delay bit is set).

       If execution is to continue after stepping over the instruction that caused the exception the program counter must  be  advanced.   If  the
       branch delay bit is set the program counter is set to the target of the branch else it is incremented by 4.

       This can be done with the following code sequence:

	   if(scp->sc_cause & CAUSE_BD)
	       emulate_branch(scp, branch_instruction);
	   else
	       scp->sc_pc += 4;

       Emulate_branch()  modifies  the	program  counter  value  in  the  sigcontext  structure to the target of the branch instruction.  See emu-
       late_branch(3) for more details.

       For SIGFPE's generated by floating-point instructions (code == 0) the floating-point control and status register at the time of the  excep-
       tion  is also saved in the sigcontext structure (sc_fpc_csr).  This register has the information on which exceptions have occurred.  When a
       signal handler is entered the register contains the value at the time of the exception but with the exceptions bits cleared.  On  a  return
       from  the  signal handler the exception bits in the floating-point control and status register are also cleared so that another SIGFPE does
       not occur (all other bits are restored from sc_fpc_csr).

       For SIGSEGV and SIGBUS errors the faulting virtual address is saved in sc_badvaddr in the signal context structure.

       The SIGTRAP's caused by break instructions noted in the above table and all other yet to be defined break instructions fill the code param-
       eter with the first argument to the break instruction (bits 25-16 of the instruction).

Return Values
       The previous action is returned on a successful call.  Otherwise, -1 is returned and errno is set to indicate the error.

Diagnostics
       The subroutine fails and action is not taken if one of the following occurs:

       [EINVAL]       The sig is not a valid signal number.

       [EINVAL]       An attempt is made to ignore or supply a handler for SIGKILL or SIGSTOP.

See Also
       kill(1), kill(2), ptrace(2), sigblock(2), sigpause(2), sigsetmask(2), sigstack(2), sigvec(2), setjmp(3), tty(4)

								       RISC								 signal(3)
All times are GMT -4. The time now is 05:02 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy