Posts

Showing posts from January, 2017

Featured Post

handling signal using c

#include #include #include #include void sig_handler(int signo) {     if (signo == SIGUSR1)         printf("received SIGUSR1\n");     else if (signo == SIGKILL)         printf("received SIGKILL\n");     else if (signo == SIGSTOP)         printf("received SIGSTOP\n"); } int main(void) {      printf("PID:--->"+getpid());     if (signal(SIGUSR1, sig_handler) == SIG_ERR)         printf("\ncan't catch SIGUSR1\n");     if (signal(SIGKILL, sig_handler) == SIG_ERR)         printf("\ncan't catch SIGKILL\n");     if (signal(SIGSTOP, sig_handler) == SIG_ERR)         printf("\ncan't catch SIGSTOP\n");     // A long long wait so that we can easily issue a signal to this process     while(1)         sleep(1); ...

functional pointer using c

#include #include #include int add(int i,int j){    return i+j; } int main(int args,char *argv[]){        int (*funcPtr)(int,int);         funcPtr=&add;         int sum =(*funcPtr)(2,3);     printf("%d\n",sum);   return 0; }

piping using c program

#include #include #include #include int main(int argc, char *argv[]) {         int     fd[2], nbytes;         pid_t   childpid;         char    string[] = "Hello, world!\n";         char    readbuffer[80];         pipe(fd);         if((childpid = fork()) == -1)         {                 perror("fork");                 exit(1);         }         if(childpid == 0)         {                 /* Child process closes up input side of pipe */                 close(fd[0]);                 printf("Val %s-%d\n",(char)...

showip using c program

#include #include #include #include #include #include #include int main(int argc, char *argv[]) {  struct addrinfo hints, *res, *p;  int status;  char ipstr[INET6_ADDRSTRLEN];  if (argc != 2) {  fprintf(stderr,"usage: showip hostname\n");  return 1;  }  memset(&hints, 0, sizeof hints);  hints.ai_family = AF_UNSPEC; // AF_INET or AF_INET6 to force version  hints.ai_socktype = SOCK_STREAM;  if ((status = getaddrinfo(argv[1], NULL, &hints, &res)) != 0) {  fprintf(stderr, "getaddrinfo: %s\n", gai_strerror(status));  return 2;  }  printf("IP addresses for %s:\n\n", argv[1]);  for(p = res;p != NULL; p = p->ai_next) {  void *addr;  char *ipver;  // get the pointer to the address itself,  // different fields in IPv4 and IPv6:  if (p->ai_family == AF_INET) { // IPv4  struct sockaddr_in *ipv4 = (struct sock...

Horton works Hadoop training

Image
Friends,     would like to share Hadoop Horton works data platform .