#!/bin/bash
# Code to set the limit on the size of the corefile
# 
setulimit(){
        set -- $(/bin/df -k ${1:-/core_files})
        typeset -i size=${11}
        if ((size > 4000000))
        then    ulimit -c unlimited
        elif ((size < 0))
        then    ulimit -c 0
        else    ulimit -c $((size*7/10))
        fi
}

#
# main
#
case "$2" in

'start')
	setulimit
	[ -d /core_files/cdd ] || mkdir -p /core_files/cdd
	cd /core_files/cdd
	"$@"
    ;;

*)
    echo "Usage: $0 sas start"
    ;;

esac
