日期:2014-05-16  浏览次数:20638 次

linux下system();函数用这用这,不能用了
我在程序中频繁的
system("umount /usr/local/thunder/medias/");
system("mount /dev/hda2 /usr/local/thunder/medias/");
一保证文件被传送的正确的位子,可是一段时间大概是460次的时候,发现system()函数不执行了。
这么会事啊???
请高手帮忙。

------解决方案--------------------
检查 mount 的提示信息和返回值。
------解决方案--------------------
探讨
查出点线索了,用showmem()函数发现内存有泄露的地方。程序很长,有什么好办法找到啊。

------解决方案--------------------
如果只是要同步写操作,sync 足够了……

According to the standard specification (e.g., POSIX.1-2001), sync() schedules the writes, but may return before
the actual writing is done. However, since version 1.3.20 Linux does actually wait. (This still does not guaran‐
tee data integrity: modern disks have large caches.)

自从 1.3.20 起,就已经改成等待同步结束再返回了。
------解决方案--------------------
study
------解决方案--------------------
学习!
------解决方案--------------------
system()->fork() or vfork(). It will cause many zombie process. And system process number is a limited number. So if you call system() many times. It will cause the system crash.
------解决方案--------------------
try unlink().
------解决方案--------------------
jjjff