Jelajahi Sumber

Terminal: Handle fork error by whining about it

AnotherTest 5 tahun lalu
induk
melakukan
2814b5a918
1 mengubah file dengan 6 tambahan dan 0 penghapusan
  1. 6 0
      Applications/Terminal/main.cpp

+ 6 - 0
Applications/Terminal/main.cpp

@@ -57,6 +57,12 @@
 static void run_command(int ptm_fd, String command)
 static void run_command(int ptm_fd, String command)
 {
 {
     pid_t pid = fork();
     pid_t pid = fork();
+    if (pid < 0) {
+        perror("fork");
+        dbg() << "run_command: could not fork to run '" << command << "'";
+        return;
+    }
+
     if (pid == 0) {
     if (pid == 0) {
         const char* tty_name = ptsname(ptm_fd);
         const char* tty_name = ptsname(ptm_fd);
         if (!tty_name) {
         if (!tty_name) {