{"action":"created","issue":{"url":"https://api.github.com/repos/uzh/gc3pie/issues/458","repository_url":"https://api.github.com/repos/uzh/gc3pie","labels_url":"https://api.github.com/repos/uzh/gc3pie/issues/458/labels{/name}","comments_url":"https://api.github.com/repos/uzh/gc3pie/issues/458/comments","events_url":"https://api.github.com/repos/uzh/gc3pie/issues/458/events","html_url":"https://github.com/uzh/gc3pie/issues/458","id":99440475,"number":458,"title":"kill() broken in the shellcmd backend","user":{"login":"GoogleCodeExporter","id":9614759,"avatar_url":"https://avatars.githubusercontent.com/u/9614759?v=3","gravatar_id":"","url":"https://api.github.com/users/GoogleCodeExporter","html_url":"https://github.com/GoogleCodeExporter","followers_url":"https://api.github.com/users/GoogleCodeExporter/followers","following_url":"https://api.github.com/users/GoogleCodeExporter/following{/other_user}","gists_url":"https://api.github.com/users/GoogleCodeExporter/gists{/gist_id}","starred_url":"https://api.github.com/users/GoogleCodeExporter/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/GoogleCodeExporter/subscriptions","organizations_url":"https://api.github.com/users/GoogleCodeExporter/orgs","repos_url":"https://api.github.com/users/GoogleCodeExporter/repos","events_url":"https://api.github.com/users/GoogleCodeExporter/events{/privacy}","received_events_url":"https://api.github.com/users/GoogleCodeExporter/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/uzh/gc3pie/labels/auto-migrated","name":"auto-migrated","color":"ededed"},{"url":"https://api.github.com/repos/uzh/gc3pie/labels/Priority-Critical","name":"Priority-Critical","color":"ededed"},{"url":"https://api.github.com/repos/uzh/gc3pie/labels/shellcmd","name":"shellcmd","color":"006b75"},{"url":"https://api.github.com/repos/uzh/gc3pie/labels/Type-Bug","name":"Type-Bug","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"arcimboldo","id":1442997,"avatar_url":"https://avatars.githubusercontent.com/u/1442997?v=3","gravatar_id":"","url":"https://api.github.com/users/arcimboldo","html_url":"https://github.com/arcimboldo","followers_url":"https://api.github.com/users/arcimboldo/followers","following_url":"https://api.github.com/users/arcimboldo/following{/other_user}","gists_url":"https://api.github.com/users/arcimboldo/gists{/gist_id}","starred_url":"https://api.github.com/users/arcimboldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcimboldo/subscriptions","organizations_url":"https://api.github.com/users/arcimboldo/orgs","repos_url":"https://api.github.com/users/arcimboldo/repos","events_url":"https://api.github.com/users/arcimboldo/events{/privacy}","received_events_url":"https://api.github.com/users/arcimboldo/received_events","type":"User","site_admin":false},"milestone":null,"comments":4,"created_at":"2015-08-06T13:57:09Z","updated_at":"2016-05-10T16:27:48Z","closed_at":"2016-05-10T16:27:48Z","body":"```\nThe `kill()` method in the ShellCmd backend is currently broken.  As\nthe following log snippet shows, it only tries to kill the single\nprocess that it spawned (i.e., `/usr/bin/time ...`), while leaving all\nof its children up and running::\n\n        gc3.gc3libs: DEBUG: Connecting to host '130.60.24.184' as user 'gc3-user' via SSH (timeout 7s)...\n        gc3.gc3libs: DEBUG: SshTransport running `kill 7232`...\n        gc3.gc3libs: DEBUG: Executed command 'kill 7232' on host '130.60.24.184'; exit code: 0\n        gc3.gc3libs: DEBUG: Deleting resource file for pid 7232\n\nHowever, the process tree looks rather like this::\n\n        gc3-user 15528  0.0  0.0   4300   348 ?        S    Jul09   0:00 /usr/bin/time -o /tmp/gc3libs.bqWIO5/.gc3pie_shellcmd/resource_usage.txt -f WallTime=%es?KernelTime=%Ss?UserTime=%Us?CPUUsage=%P?MaxResidentMemory=%MkB?AverageResidentMemory=%tkB?AverageTotalMemory=%KkB?AverageUnsharedMemory=%DkB?AverageUnsharedStack=%pkB?AverageSharedMemory=%XkB?PageSize=%ZB?MajorPageFaults=%F?MinorPageFaults=%R?Swaps=%W?ForcedSwitches=%c?WaitSwitches=%w?Inputs=%I?Outputs=%O?SocketReceived=%r?SocketSent=%s?Signals=%k?ReturnCode=%x /bin/sh -c  \"./gcelljunction_wrapper.sh\" \"-x\" \"./tricellular_junctions_new\" \"--\" \"38\"\n        gc3-user 15529  0.0  0.0   4404   584 ?        S    Jul09   0:00  \\_ /bin/sh -c  \"./gcelljunction_wrapper.sh\" \"-x\" \"./tricellular_junctions_new\" \"--\" \"38\"\n        gc3-user 15530  0.0  0.0  11044  1412 ?        S    Jul09   0:00      \\_ /bin/bash ./gcelljunction_wrapper.sh -x ./tricellular_junctions_new -- 38\n        gc3-user 15535 53.7  2.1 1434392 175608 ?      Sl   Jul09 30838:45          \\_ ./tricellular_junctions_new 38\n\nNow this has also a very bad unintended consequence: since GC3Pie\ndeletes the resource file, the VM slot is then marked as free to run\nother jobs, which it isn't  -- this is how we ended up having two\nprocesses running in Tinri's VMs.\n\nA good way to do the killing on Linux should be to kill all processes\nthat run in the same temporary directory::\n\n    ec2ssh -n \"gc3-user@$ip\" \"find /proc/*/cwd -maxdepth 0 -printf '%p %l\\n' 2>/dev/null | egrep '${cwd}\\$'\" 2>/dev/null | \\\n        (while read proc wd; do\n           pid=$(echo \"$proc\" | cut -d/ -f3)\n           #echo \"DEBUG: pid=$pid\"\n           #ec2ssh -n \"gc3-user@$ip\" \"ps --no-headers u '$pid'\" 2>/dev/null\n           ec2ssh -n \"gc3-user@$ip\" \"kill $pid\" 2>/dev/null\n        done)\n\nI am not sure if the MacOSX `/proc` provides the same information,\nthough.\n\n```\n\nOriginal issue reported on code.google.com by `riccardo.murri@gmail.com` on 18 Aug 2014 at 12:48"},"comment":{"url":"https://api.github.com/repos/uzh/gc3pie/issues/comments/218213399","html_url":"https://github.com/uzh/gc3pie/issues/458#issuecomment-218213399","issue_url":"https://api.github.com/repos/uzh/gc3pie/issues/458","id":218213399,"user":{"login":"arcimboldo","id":1442997,"avatar_url":"https://avatars.githubusercontent.com/u/1442997?v=3","gravatar_id":"","url":"https://api.github.com/users/arcimboldo","html_url":"https://github.com/arcimboldo","followers_url":"https://api.github.com/users/arcimboldo/followers","following_url":"https://api.github.com/users/arcimboldo/following{/other_user}","gists_url":"https://api.github.com/users/arcimboldo/gists{/gist_id}","starred_url":"https://api.github.com/users/arcimboldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/arcimboldo/subscriptions","organizations_url":"https://api.github.com/users/arcimboldo/orgs","repos_url":"https://api.github.com/users/arcimboldo/repos","events_url":"https://api.github.com/users/arcimboldo/events{/privacy}","received_events_url":"https://api.github.com/users/arcimboldo/received_events","type":"User","site_admin":false},"created_at":"2016-05-10T16:27:48Z","updated_at":"2016-05-10T16:27:48Z","body":"Tested on a MacOSX 10.6 used as remote shellcmd resource, it seems to work."}}