C program which illustrates sending signal from one process to another by using kill API. Also check if the program have permission to send the signal or not

#include#include#include#include#include#includevoid sig_handler(int num){printf("nChild Sent a signal to parent:%dn",num);signal(SIGALRM,SIG_DFL);}int main(){int status;system("clear");printf("n--------Signal Handling Across Processes----------n");switch(fork()){case -1:perror("nFork Failed...n");exit(1);break;case 0:alarm(3);kill(getppid(),SIGALRM);//signal(SIGALRM,sig_handler);printf("nIts Child Processn");sleep(5);break;default:signal(SIGALRM,sig_handler);wait(&status);printf("nIts Parent Processn");}return 0;}

Continue ReadingC program which illustrates sending signal from one process to another by using kill API. Also check if the program have permission to send the signal or not

C Program to register signal handler for SIGTERM and when it receives the signal, the program should print some information about the origin of the signal

#include #include #include #include struct sigaction act; void sighandler(int signum, siginfo_t *info, void *ptr) { printf("Received signal %dn", signum); printf("Signal originates from process %lun", (unsigned long)info->si_pid); } int main() {…

Continue ReadingC Program to register signal handler for SIGTERM and when it receives the signal, the program should print some information about the origin of the signal

C program that accepts a valid directory names as a command line argument and lists all the files in the given directory as well as all the subsequent sub directories

#include #include #include int myfun(const char *pathname,const struct stat *statptr,int type); int main(int argc,char *argv[]) { nftw(argv[1],myfun,0,0); exit(0); } int myfun(const char *pathname,const struct stat *statptr,int type) { if(type==FTW_F) printf("nfile…

Continue ReadingC program that accepts a valid directory names as a command line argument and lists all the files in the given directory as well as all the subsequent sub directories