LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 03-06-2012, 11:57 PM   #1
ashish061291
LQ Newbie
 
Registered: Jan 2012
Posts: 16

Rep: Reputation: Disabled
how to pass "ctrl+c" to terminal


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..
 
Old 03-07-2012, 12:24 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Assuming you are running blktrace from the Perl script, you could send a signal to the blktrace process. SIGINT is the equivalent of using Ctrl+C in a terminal.
 
1 members found this post helpful.
Old 03-07-2012, 12:29 AM   #3
ashish061291
LQ Newbie
 
Registered: Jan 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
Ya i got that.
Thanks a ton

But actually I am new to Ubuntu so can u explain in detail as in how can I achieve it ??
 
Old 03-07-2012, 03:09 AM   #4
pgpython
Member
 
Registered: Dec 2005
Location: Sheffield, UK
Distribution: Gentoo
Posts: 142

Rep: Reputation: 32
according to the man page on kill SIGINT is signal num 2 so in your perl script you would simply do kill -2 <process id>
 
Old 03-07-2012, 03:45 AM   #5
ashish061291
LQ Newbie
 
Registered: Jan 2012
Posts: 16

Original Poster
Rep: Reputation: Disabled
But 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.
 
Old 03-07-2012, 07:07 AM   #6
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Quote:
Originally Posted by ashish061291 View Post
I can find the pid by using system("pidof -s blktrace");, but then how can i use this information further to stop blktrace execution.
I don't Perl but something like
Code:
@blktrace_PID = `system("pidof -s blktrace");`
The ` characters are backquotes.
 
  


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
[SOLVED] "Insert" & "Delete" key returns "~" in a terminal. sharky Linux - General 15 04-26-2011 08:36 AM
Hardy won't startup, stops with a "fail" and I have to "ctrl+alt+del" to boot. brjoon1021 Ubuntu 10 12-15-2008 06:29 PM
"GRUB _" when booting, nothing but "ctrl+alt+del" functions rabidpencil Linux - Newbie 15 08-08-2006 10:20 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 04:09 AM.

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