Quantcast
Channel: Active questions tagged windows-subsystem-for-linux - Ask Ubuntu
Viewing all articles
Browse latest Browse all 2930

sleep() function in C doesn't work on Ubuntu 20.04 (WSL). Is there any way to make the sleep() work?

$
0
0

I am using a Windows app for Ubuntu to practice C/C++ code.

Eventually I found that sleep() call does not work here. I went through the answers provided earlier on other posts but could not find any relevant solution for it.

So I just want to know whether there is any way to make sleep() or a similar kind of waiting call to work on same Ubuntu application?

Example code:

#include<stdio.h>#include<stdlib.h>#include<unistd.h>#include<signal.h>void handler(int num){        write(STDOUT_FILENO, "I am in handler...handling signal\n", 13);}int main(int argc, char **argv){        signal(SIGINT, handler);        signal(SIGTERM,handler);        while(1)        {                printf("Just wasting your time! PID = %d\n", getpid());                sleep(1);        }}

Viewing all articles
Browse latest Browse all 2930

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>