- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- How to stop an endless loop with trap?
Operating System - HP-UX
1823986
Members
4388
Online
109667
Solutions
Forums
Categories
Company
Local Language
юдл
back
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Forums
Discussions
Discussions
Discussions
Forums
Forums
Discussions
юдл
back
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Blogs
Information
Community
Resources
Community Language
Language
Forums
Blogs
Go to solution
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-18-2002 06:07 PM
тАО10-18-2002 06:07 PM
How do I stop my while loop by using 'trap'? I don't want my shell script to use ctrl-c.
-------------
#!/bin/sh
trap '???' ? #Problem: How to trap?
while:
do
echo Program is looping
done
-------------
How can I kill it while I'm having an endless loop?
-------------
#!/bin/sh
trap '???' ? #Problem: How to trap?
while:
do
echo Program is looping
done
-------------
How can I kill it while I'm having an endless loop?
Solved! Go to Solution.
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-18-2002 06:37 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-19-2002 03:16 AM
тАО10-19-2002 03:16 AM
Re: How to stop an endless loop with trap?
give this link a once over:
http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x022718276953d61190040090279cd0f9,00.html
live free or die
harry
Live Free or Die
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО10-19-2002 04:54 AM
тАО10-19-2002 04:54 AM
Re: How to stop an endless loop with trap?
Hi,
well, why not use signal #1 (SIGHUP) and send that signal from another shell-session to that running script?
trap "echo trapped" 1 # set trap
#your loop here
trap "" 1 # release trap
Now you start it, say into the background:
./your-script & # now $! is the PID of this process
pid=$!
And finally, as soon as you decide to stop it:
kill -1 $pid
HTH,
Wodisch
well, why not use signal #1 (SIGHUP) and send that signal from another shell-session to that running script?
trap "echo trapped" 1 # set trap
#your loop here
trap "" 1 # release trap
Now you start it, say into the background:
./your-script & # now $! is the PID of this process
pid=$!
And finally, as soon as you decide to stop it:
kill -1 $pid
HTH,
Wodisch
The opinions expressed above are the personal opinions of the authors, not of Hewlett Packard Enterprise. By using this site, you accept the Terms of Use and Rules of Participation.
Company
Learn About
News and Events
Support
© Copyright 2025 Hewlett Packard Enterprise Development LP