Facebook
From Melodic Octupus, 4 Years ago, written in C#.
This paste is a reply to Re: Re: Re: Re: Re: Re: Re: ss from Sloppy Finch - view diff
Embed
Download Paste or View Raw
Hits: 104
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <unistd.h>
  4. #include <sys/sem.h>
  5. #include <sys/stat.h>
  6. int main( int argc,char** argv )
  7. {
  8.  int nsems,semflag,semid;
  9.  key_t key;
  10. if( argc>1 )
  11. {
  12.  sscanf( argv[1],"%d",&nsems )
  13. if( nsems>0 )
  14. {
  15. key = ftok( "/tmp",'a'+'t'+'h'+'r'+'i'+'r' );
  16. printf( "[pid=%u] tworzy zbiór %d semaforów [key=%x]\n",
  17. (unsigned)getpid(),nsems,(unsigned)key );
  18. semflag = IPC_CREAT | S_IRUSR | S_IWUSR;
  19. semid = semget( key,nsems,semflag );
  20. if( semid==-1 ){ perror( "\tsemget()..." ); exit( 3 ); }
  21. else
  22. {
  23. if( semctl( semid,0x0,IPC_RMID) == -1)
  24. { perror("\tsemctl()"); exit(1); }
  25. }
  26. }
  27. else
  28.   { printf( "\t%s [%s]\n%s",argv[0],"n",
  29. "\tn -rozmiar tworzonej tablicy semaforów\n" ); exit( 1 ); }
  30. return 0;
  31. }}

Replies to Re: Re: Re: Re: Re: Re: Re: Re: ss rss

Title Name Language When
Re: Re: Re: Re: Re: Re: Re: Re: Re: ss Putrid Frog csharp 4 Years ago.