EzDevInfo.com

kill interview questions

Top kill frequently asked interview questions

Killing a defunct process on UNIX system [closed]

I have a defunct process on my system:

abc      22093 19508  0 23:29 pts/4    00:00:00 grep ProcA
abc      31756     1  0 Dec08 ?        00:00:00 [ProcA_my_collect] <defunct>

How can I kill the above process, without a reboot of the machine? I have tried with

kill -9 31756
sudo kill -9 31756

Source: (StackOverflow)

How do I kill a process using Vb.NET or C#?

I have a scenario where I have to check whether user has already opened Microsoft Word. If he has, then I have to kill the winword.exe process and continue to execute my code.

Does any one have any straight-forward code for killing a process using vb.net or c#?


Source: (StackOverflow)

Advertisements

Is there any way to kill a Thread in Python?

Is it possible to terminate a running thread without setting/checking any flags/semaphores/etc.?


Source: (StackOverflow)

What does `kill -0 $pid` in a shell script do?

Basically, what signal does '0' represent, because here I see SIGNAL numbers starting from 1.


Source: (StackOverflow)

How to cleanly shutdown Eclipse from Linux command line?

Is there a way to shutdown Eclipse cleanly from the command line, such that files and workspaces are saved? kill -3 doesn't do anything. kill -1 and kill -15 (default) causes Eclipse to exit abruptly with JVM termination popup. kill -9 does the same thing.

The use case is that I'm working remotely on a machine with Eclipse loaded on it, and I want to save memory by closing Eclipse, but I want Eclipse to save its state first.

I could use VNC or some alternative desktop sharing software, but that's really heavy-weight, and I'd much prefer a command line solution.

EDIT: System info: RHEL5.1 64-bit using GNOME


Source: (StackOverflow)

Kill Activity on back button

Ok, I got an activity, that when it starts, it loads an image from the internet, and, trying to save memory, when the activity is left (the back button being pressed), I want the activity to dump (get rid of all the strings and images that are in it). So, I figure the best way to do this is to just kill the activity. Well, I cant seem to figure out the callback for when the backbutton is pressed, so I have been trying to use the onPause and onStop callbacks for the task, but botch ways force close my app. Im trying this

public void onPause() {
this.finish();
}
public void onStop() {
finish();
}

Ive tried multiple variations of this, but none of them seem to work. Any ideas?


Source: (StackOverflow)

When a parent process is killed by "kill -9", will subprocess also be killed?

One of my colleague told me this morning, when he killed supervisord by "kill -9", the subprocesses of supervisord is not killed.

He is quite sure about that, but I tried many times and did not find that happen.

So when a parent process is killed by "kill -9", will linux ensure that it's sub-processes also been killed?


Source: (StackOverflow)

What happens if you kill a long-running alter query?

What happens if you kill a long-running alter query? Will the alter query simply revert? How long could that take (as a proportion of the time it has already been running)?

What if that query is being replicated onto another server? Will killing the process on the other server revert the original server's alter query?

We're running mysql


Source: (StackOverflow)

How to kill a process in cygwin?

Hi i have the following process which i cant kill:

The process to be killed.

I am running cygwin in windows xp 32 bit.

I have tried issuing the following commands:

/bin/kill -f 4760
/bin/kill -9 5000
kill -9 5000
kill 5000

When i write /bin/kill -f 4760 i get the message, 'kill: couldn't open pid 4760'.

When i write /bin/kill -9 5000 i get the message, 'kill: 5000: No such process'.

I simply don't understand why this process cant be killed. Since it has a WINID shouldnt it be killed by /bin/kill -f 4760?

hope someone can help thx :)


Source: (StackOverflow)

What does 'killed' mean?

I have a Python script that imports a large CSV file and then counts the number of occurrences of each word in the file, then exports the counts to another CSV file.

But what is happening is that once that counting part is finished and the exporting begins it says Killed in the terminial.

I don't think this is a memory problem (if it was I assume I would be getting a memory error and not Killed).

Could it be that the process is taking too long? If so, is there a way to extend the time-out period so I can avoid this?

Here is the code:

csv.field_size_limit(sys.maxsize)
    counter={}
    with open("/home/alex/Documents/version2/cooccur_list.csv",'rb') as file_name:
        reader=csv.reader(file_name)
        for row in reader:
            if len(row)>1:
                pair=row[0]+' '+row[1]
                if pair in counter:
                    counter[pair]+=1
                else:
                    counter[pair]=1
    print 'finished counting'
    writer = csv.writer(open('/home/alex/Documents/version2/dict.csv', 'wb'))
    for key, value in counter.items():
        writer.writerow([key, value])

And the Killed happens after finished counting has printed, and the full message is:

killed (program exited with code: 137)

Source: (StackOverflow)

Prevent Activity Stack from being Restored?

When an application's process is killed, its activity stack is saved. Then when the application is restarted, all my activities resume and run into null pointers. Rather than modify every activity to accommodate this event, I would rather just have my application start with the base activity and not try to re-create the activity stack.

Is this possible?

I know about Intent.FLAG_ACTIVITY_CLEAR_TOP, but as I understand that will only kill activities after they have been re-created.

EDIT: is clearTaskOnLaunch what I want? I've added it to my default activity, but am seeing no effect. But this will kill my activities even if I just minimize the application, wont it? I'd rather only clear the stack if the entire process is rebooting.

EDIT 2: No, it's not what I want- an Android engineer gave a thorough response to some questions on how to use ClearTaskOnLaunch: http://groups.google.com/group/android-developers/browse_thread/thread/da024bcaf4e1960f/ab1e2b35c360cb65?pli=1


Source: (StackOverflow)

How to kill an application with all its activities? [duplicate]

Possible Duplicate:
Quitting an application - is that frowned upon?

I want to offer the user an option to exit the application as I need to delete some sensitive data, which is stored in the SharedPreferences as long as the application needs it.

As soon as the user wants to exit, the password in the SharedPreferences should be wiped and of course all activities of the application should be closed (it makes no sense to run them without the known password - they would crash).

How can I do that?

System.exit(0) and finish() only exit the current activity - useless. I know there is a taskmanager app. How is that one doing it? It's able to kill the whole application...


Source: (StackOverflow)

Starting apache fails (could not bind to address 0.0.0.0:80)

Update: Already fixed, it seems that one of VirtualHosts configurations files was wrong in sites-enabled.

I have Ubuntu 11.10

When I run the command to start apache2:

sudo /etc/init.d/apache2 start

I get the following error message:

Starting web server apache2
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName (98)Address already in use: make_sock: could not bind to address 0.0.0.0:80 no listening sockets available, shutting down Unable to open logs Action 'start' failed.

I run this command in order to get the process that is using the port 80:

sudo netstat -ltnp | grep ':80'

Which returns this output:

tcp6       0      0 :::80                   :::*                    LISTEN      1176/

To know which process is I run this command:

ps -wlp1176

That returns:

F S   UID   PID  PPID  C PRI  NI ADDR SZ WCHAN  TTY          TIME CMD
5 D    33  1176     1  0  80   0 -     0 exit   ?        00:00:00 apache2

But if I try to kill the process:

sudo kill -9 1176

It doesn't kill it, if I run again the netstat command still appears listening and apache start fails.

Any suggestions?


Source: (StackOverflow)

Why number 9 in kill -9 command in unix?

I understand it's off topic, I couldn't find anywhere online and I was thinking maybe programming gurus in the community might know this.
I usually use

kill -9 pid

to kill the job. I always wondered the origin of 9. I looked it up online, and it says

"9 Means KILL signal that is not catchable or ignorable. In other words it would signal process (some running application) to quit immediately" (source: http://wiki.answers.com/Q/What_does_kill_-9_do_in_unix_in_its_entirety)

But, why 9? and what about the other numbers? is there any historical significance or because of the architecture of Unix?


Source: (StackOverflow)

How can I kill all sessions connecting to my oracle database?

I need to quickly (and forcibly) kill off all external sessions connecting to my oracle database without the supervision of and administrator.

I don't want to just lock the database and let the users quit gracefully.

How would I script this?


Source: (StackOverflow)