'Emulates the most basic behavior of Linux\'s flock(1).'

def ExecFlock(self, lockfile, *cmd_list):

    fd = os.open(lockfile, ((os.O_WRONLY | os.O_NOCTTY) | os.O_CREAT), 438)
    if sys.platform.startswith('aix'):
        op = struct.pack('hhIllqq', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
    else:
        op = struct.pack('hhllhhl', fcntl.F_WRLCK, 0, 0, 0, 0, 0, 0)
    fcntl.fcntl(fd, fcntl.F_SETLK, op)
    return subprocess.call(cmd_list)
