Clear the cgroups memory usage at exit

When finishing up set the created cgroups memory usage to 0 to prevent
any usage being moved over to the parent group.

See section 5.1 of Documentation/cgroups/memory.txt in the Kernel
source.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Re-factor the code a little in preperation for signal handling

Re-work the fork / if / else code in preperation for signal handling
code to properly handle lemem and child process termination.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Introduce proper signal handling

Handle various situations cleanly :-

    - lemem being sent SIGINT (e.g Ctrl-c) and SIGTERM
    - The child process terminating

In the above cases we make sure the control group cleanup happens,
whereas before we could be left with the created control group being
left behind.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Factor out the cgroup cleanup code into its own function

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Check that the execvp(3) worked

If not, perror and exit.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Tidy up child snprintf()'s

We can use the cgpath variable instead of MEM_CGROUP_MNT_PT + sprog.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>