def check_foreground():
    ''' function that returns True if the process executing this module
        is in foreground. If in background, this module won't
        print to stderr/stdout.
    '''
    if(not platform.system().lower().startswith('linux')):
        return True
    try:
        if(os.getpgrp() == os.tcgetpgrp(sys.stdout.fileno())):
            return True
    except OSError:
        pass
    return False