读书人

linux下system();函数用这用这不能用

发布时间: 2012-03-08 13:30:13 作者: rapoo

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

读书人网 >UNIXLINUX

热点推荐