LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 05-29-2008, 09:26 AM   #1
timepassman
LQ Newbie
 
Registered: Apr 2008
Posts: 3

Rep: Reputation: 0
Question catch event or kill application when started..


hi,
i wish 2 write a program to prevent user from starting an application say firefox during a time period.

how can i catch the event when the application is started? one way is to check every minute/second using pgrep or ps.

Is there any other better way?

(OS: ubuntu)

Last edited by timepassman; 05-29-2008 at 09:27 AM. Reason: more info added
 
Old 05-29-2008, 10:44 AM   #2
ntubski
Senior Member
 
Registered: Nov 2005
Distribution: Debian, Arch
Posts: 3,780

Rep: Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081Reputation: 2081
You could remove executable permission from the binary file, chmod -x <path to executable>
 
Old 05-29-2008, 10:51 AM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 65
It's not easy to make it water-tight, but you might try something like this:

using cron, at the beginning of the period where you want to prevent users from running it, change the permissions on the firefox binary so it is not executable, and use killall to kill running firefox-bin processes.

When you want to allow access to firefox, just re-add the execute permission.

Note that the file /usr/bin/firefox is actually a symlink, and this is often to a wrapper script, not to th actual binary. On Hardy Heron, the actual firefox binary is /usr/lib/firefox-3.0b5/firefox.

Be aware that this method will not prevent a user running a different copy of firefox - -perhaps one installed into their home directory. Like I said, it's not easy to make it water-tight.
 
  


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
force kill application ahmad19 Linux - Newbie 3 04-08-2008 01:33 PM
How to kill a process or application vitalstrike82 SUSE / openSUSE 1 02-16-2008 10:23 AM
Create and catch own event bianchi Programming 0 11-29-2005 06:30 AM
kill procesed application fireedo SUSE / openSUSE 4 05-10-2005 11:24 AM
CATCH mouse event!!! hongzhang Linux - Software 0 08-07-2003 02:19 AM

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

All times are GMT -5. The time now is 12:43 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