我在后台运行countryServer之后杀死了它,这是我遇到的问题。我尝试重新编译一个新版本,这就是我得到的
root@ubuntu:/home/baoky/shell_assignment/shell_assn2# g++ -o countryServer CountryServer.cpp
root@ubuntu:/home/baoky/shell_assignment/shell_assn2# ./countryServer &
[1] 3097
root@ubuntu:/home/baoky/shell_assignment/shell_assn2#
Running server program 'css' ......
Country Directory server started
root@ubuntu:/home/baoky/shell_assignment/shell_assn2# ps
PID TTY TIME CMD
2993 pts/3 00:00:00 su
3001 pts/3 00:00:00 bash
3097 pts/3 00:00:00 countryServer
3098 pts/3 00:00:00 ps
root@ubuntu:/home/baoky/shell_assignment/shell_assn2# kill 3097
[1]+ Terminated ./countryServer
root@ubuntu:/home/baoky/shell_assignment/shell_assn2# g++ -o countryServer CountryServer.cpp
/usr/bin/ld: cannot open output file countryServer: No such device or address
collect2: ld returned 1 exit status
root@ubuntu:/home/baoky/shell_assignment/shell_assn2# ls -l
total 60
-rw-r--r-- 1 baoky baoky 19545 Aug 2 10:33 Countries.txt
-rwxr-xr-x 1 root root 14756 Aug 4 03:17 countryClient
-rw-r--r-- 1 baoky baoky 3514 Aug 4 03:19 CountryClient.cpp
-rw-r--r-- 1 baoky baoky 4740 Aug 4 2012 CountryData.c
-rw-r--r-- 1 baoky baoky 2022 Aug 2 10:33 CountryData.h
srwxr-xr-x 1 root root 0 Aug 4 03:29 countryServer
-rw-r--r-- 1 baoky baoky 7762 Aug 4 03:18 CountryServer.cpp
我收到一个错误,返回了这个
/ usr / bin / ld:无法打开输出文件countryServer:没有这样的设备或地址
collect2:ld返回1退出状态
如果我执行rm -rf countryServer,我可以修复它
但是我如何解决它,以便它可以覆盖旧的countryServer(在我杀死它的进程并重新编译之后)
最佳答案
您的countryServer
程序似乎正在当前目录中创建一个名为countryServer
的套接字文件,并在此过程中覆盖自身。
在编译代码之前,请删除该套接字文件,或者更好的方法是:更改代码,以免覆盖自己的可执行文件。