多模态强化学习框架PyVision-RL开发实战
2026/5/4 2:02:26
在Linux系统中,工作目录的管理十分重要。以下代码展示了如何保存当前工作目录,切换到其他目录,完成工作后再返回原目录:
int swd_fd; swd_fd = open (".", O_RDONLY); if (swd_fd == -1) { perror ("open"); exit (EXIT_FAILURE); } /* change to a different directory */ ret = chdir (some_other_dir); if (ret) { perror ("chdir"); exit (EXIT_FAILURE); } /* do some other work in the new directory... */ /* return to the saved directory */ ret = fchdir (swd_fd); if (ret) { perror ("fchdir"); exit (EXIT_FAILURE); } /* close the directory's fd */ ret = close (swd_fd); if (ret) { perror ("close"); exit (EXIT_FAILURE); }这个过程其实就是shell实现缓存上一个目录的方式,例如在bash中使用cd -命令。不同类型的进程对工作目录有不同的设置:
- 像守护进程这类不关心当前工作目录的进程,通