首页| 论坛| 消息

标题:arm下程序调用外部程序更新后再加载程序失败
作者:pamire
日期:2016-05-17 17:04
内容:

开发环境:
ubuntu15 x64 + qte 4.8.6 + arm
Linux EmbedSky 3.0.35 #46 SMP PREEMPT Tue Mar 29 17:26:50 CST 2016 armv7l GNU/Linux(天嵌开发板)
1. 现象:
主程序A调用外部程序B,并且A退出, B解压 更新程序后再次加载A,则加载A失败。
原因不明,也写不了日志。
2.现象:
若直接运行B, B解压 更新程序后加载A,则加载A成功,写不了日志(笔误)。
3.现象:
在xp下测试反复循环加载正常,能写日志。

B程序主要代码:

QString g_currentPath;
int DoUnzip(QString sUpdatePackName, QString sUnzipPackPath)
{

qDebug()


#1 [uidab 05-18 09:13]
什么叫做 " 能写不了日志"????
你用的是start启动的,在linux和xp这种情况是有不同的。
#2 [pamire 05-18 10:22]
经过反复测试,问题跟踪到
(此拷贝程序反复测试,也找了类似的,基本思路都一样,感觉不应该是程序的事,可能与QProgress调用有关)
//拷贝文件夹:

//拷贝文件夹:
bool copyDirectoryFiles(const QString &fromDir, const QString &toDir, bool coverFileIfExist)
{
QDir sourceDir(fromDir);
QDir targetDir(toDir);
if(!targetDir.exists()){/**< 如果目标目录不存在,则进行创建 */
if(!targetDir.mkdir(targetDir.absolutePath()))
return false;
}
QFileInfoList fileInfoList = sourceDir.entryInfoList();
foreach(QFileInfo fileInfo, fileInfoList){
if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
continue;

/**< 当为目录时,递归的进行copy */
if(fileInfo.isDir())
{
if(!copyDirectoryFiles(fileInfo.filePath(), targetDir.filePath(fileInfo.fileName()), coverFileIfExist))
return false;
}
else /**< 当允许覆盖操作时,将旧文件进行删除操作 */
{
if(coverFileIfExist && targetDir.exists(fileInfo.fileName())){
&nb ..
#3 [pamire 05-18 11:36]
解法方法:
1. 用exec,execl, execv等
#include
  int execl(cONst char *path, const char *arg, ...);
  int execlp(const char *file, const char *arg, ...);
  int execle(const char *path, const char *arg, ..., char *const envp[]);
  int execv(const char *path, char *const argv[]);
  int execvp(const char *file, char *const argv[]);
  int execve(const char *path, char *const argv[], char *const envp[]);
"/mnt/nfs/bin/UpdateQt/mnt/nfs/bin/update.zip"
QLock::lock(): Invalid argument
QLock::unlock(): Unlock without corresponding lock
QLock::lock(): Invalid argument
QLock::unlock(): Unlock without corresponding lock
QLock::lock(): Invalid argument
QLock::unlock(): Unlock without corresponding lock
用execl出现上面调用失败信息
2.改进调用QProgress
int IClient::DoUnzip()
{
#ifdef _WIN32
QString progra = QString("%1/UpdateQt.exe").arg(g_env.filePathInfo.strAppPath);
#else
QString progra = QString("%1/UpdateQt").arg(g_env.filePathInfo.strAppPath);
#endif
QStringList arguents;
arguents setWorkingDirectory(g_env.filePathInfo.strAppPath);
myProcess->start(progra, arguents);
while (! myProcess->waitForFinished(300)) {
if (myProcess->state() == QProcess::NotRunning) { //process failed
printf("NotRunning\n");
return -1;
}
qApp->processEvents();
}
..

回复 发表
主题 版块