mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:47:45 +00:00
Userland: Port sleep(1) to Core::ArgsParser
This commit is contained in:
parent
27360f1f20
commit
62283ade91
1 changed files with 7 additions and 11 deletions
|
@ -24,7 +24,7 @@
|
||||||
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <AK/String.h>
|
#include <LibCore/ArgsParser.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
@ -41,16 +41,12 @@ int main(int argc, char** argv)
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc != 2) {
|
int secs;
|
||||||
printf("usage: sleep <seconds>\n");
|
|
||||||
return 1;
|
Core::ArgsParser args_parser;
|
||||||
}
|
args_parser.add_positional_argument(secs, "Number of seconds to sleep for", "num-seconds");
|
||||||
bool ok;
|
args_parser.parse(argc, argv);
|
||||||
unsigned secs = String(argv[1]).to_uint(ok);
|
|
||||||
if (!ok) {
|
|
||||||
fprintf(stderr, "Not a valid number of seconds: \"%s\"\n", argv[1]);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
struct sigaction sa;
|
struct sigaction sa;
|
||||||
memset(&sa, 0, sizeof(struct sigaction));
|
memset(&sa, 0, sizeof(struct sigaction));
|
||||||
sa.sa_handler = handle_sigint;
|
sa.sa_handler = handle_sigint;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue