在RedHat机器上运行C ++代码之前,等待解压缩完成 [英] Waiting for unzip to finish before carrying on C++ code on a RedHat machine

查看:163
本文介绍了在RedHat机器上运行C ++代码之前,等待解压缩完成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要在我的Redhat机器上解压缩一个压缩文件夹。

I want to unzip a zipped folder on my Redhat machine.

为此,我发送一个bash脚本字符串;

To do this I send a bash script the string;

"unzip /usr/bin/Folder.gz"

这解压文件夹没有问题,因为我得到一般的

This unzips the folder no problem, as in I get the general

inflating folderA/folderB/fileX

等。

但是,我想在unzip命令中保存代码,等待解压缩完成。

However, I want to hold the code at the unzip command, waiting until the unzipping is complete.

我尝试使用

sleep(5)

但我不想使用这个,只是希望它总是需要不到五秒,特别是这是非常小的压缩文件是低效的。

but I don’t want to use this and just hope that it will always take less than five seconds especially this is would be inefficient for very small zipped files.

我已在网上搜索,但无效...

I have searched online but to no avail...

所以我的问题是;在解压缩完成之前,什么是阻止程序的可靠方法?

So my question is; what is a reliable way to stall a program until the unzipping is complete?

O / S:Redhat

O/S: Redhat

编程语言:C ++

IDE:Eclipse

IDE: Eclipse

推荐答案

如何运行bash脚本?

How do you run the bash script?

如果使用 system() API将启动程序,然后等待生成的进程结束。

If you use the system() API it will start the program and then wait until the spawned process ends.

system()调用由其他3个系统调用组成:execl(),wait()和fork()。 来源

system() system is a call that is made up of 3 other system calls: execl(), wait() and fork(). Source.

这篇关于在RedHat机器上运行C ++代码之前,等待解压缩完成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆