×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

how to pass "ctrl+c" to terminal

how to pass "ctrl+c" to terminal

how to pass "ctrl+c" to terminal

(OP)
Hi everyone,

I am executing "blktrace" on my /dev/sda.
In my application i have made a GUI which lets user to choose when he wants to stop "blktrace" execution.

Now how can achieve it ??

Also how can i pass "Ctrl+C" to terminal from a perl script ??


Kindly help..

RE: how to pass "ctrl+c" to terminal

Hi

Using the kill function :

CODE --> Perl

kill SIGINT, $pid_of_blktrace;

# or

kill 2, $pid_of_blktrace;

Quote (ashish061291):

wants to stop "blktrace" execution.
(...)
Also how can i pass "Ctrl+C" to terminal from a perl script ??
Note that there is contradiction : SIGSTOP, which is used to suspends the process, is not the same with the SIGINT sent by Ctrl-C, which interrupts the process.

Feherke.
http://feherke.github.com/

RE: how to pass "ctrl+c" to terminal

(OP)
Thnx a ton :)

But is there any way if I can replace $pid_of_blktrace by the process name ??

RE: how to pass "ctrl+c" to terminal

(OP)
And as i run again and again its pid changes every time.

I can find the pid by using system("pidof -s blktrace");, but then how can i use this information further to stop blktrace execution.

RE: how to pass "ctrl+c" to terminal

Hi

Quote (ashish061291):

But is there any way if I can replace $pid_of_blktrace by the process name ??
As far as I know, not with Perl core functionality. There would be some alternatives :
  • There should be no need for that. Supposing blktrace was also started by your Perl script, its PID should be known by it.
  • Find out the PID using a module, for example Proc::ProcessTable.
  • Find out the PID by reading the /proc/ directory.
  • Use external command instead :

    CODE --> Perl

    system 'killall SIGINT blktrace';

    # or

    system 'pkill -SIGINT blktrace';

Feherke.
http://feherke.github.com/

RE: how to pass "ctrl+c" to terminal

(OP)
Thnk u vry vry much :)
It worked :)

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close