while 1: commande = input('Entrez une commande \n') pid = os.fork() lng = len(commande) dernierchar = commande[lng - 1] tblcmd = commande.split() status = 0 if pid == 0: if dernierchar == '&': try: os.execvp(tblcmd[0], tblcmd[0:len(tblcmd) - 1]) except OSError as e: errno = e.get_er os.sterror('Commande inconnue ', e.strerror) fflush(stdout) else: try: os.execvp(tblcmd[0], tblcmd[0:]) except OSError as e: errno = e.get_er os.sterror('Commande inconnue ', e.strerror) fflush(stdout) elif pid > 0: if dernierchar == '&': print('Execution en arriere plan') else: status = os.wait() print('Pid du fils ', status[0])
def __init__(self, error_message): if hasattr(errno, 'ETIME'): self.message = os.sterror(errno.ETIME) else: self.messaage = error_message
def __init__(self, error_message): if hasattr(errno, "ETIME"): self.message = os.sterror(errno.ETIME) else: self.messaage = error_message