[ kunc @ 22.05.2015. 22:08 ] @
Znaci obični program, skolski primjer. Trebam dodat na ovaj cod jednu sistemsku funkciju..bilo koju, bilo kakvu. Moze li neko pomoći i slično ?! Hvala unaprijed
Code:
#include <stdio.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <stdlib.h>
int Id; /* identifikacijski broj segmenta */
int *ZajednickaVarijabla;
 
void Pisac(int i)
{
   *ZajednickaVarijabla = i;
}
void Citac(void)
{
   int i;
   do {
      i = *ZajednickaVarijabla;
      printf("Procitano %d\n", i);
      sleep(1);
   } while (i == 0);
   printf("Procitano je: %d\n", i);
}
void brisi(int sig)
{
   /* oslobađanje zajedničke memorije */
   (void) shmdt((char *) ZajednickaVarijabla);
   (void) shmctl(Id, IPC_RMID, NULL);
   exit(0);
}
int main(void)
{
   /* zauzimanje zajedničke memorije */
   Id = shmget(IPC_PRIVATE, sizeof(int)*100, 0600);
   /* sizeof(int) je dovoljno memorije, ali u nekim slucajevima (pinus) 
      treba zatraziti vise memorije, pa je u primjeru broj pomnozen sa 100 */
 
   if (Id == -1)
      exit(1);  /* greška - nema zajedničke memorije */
 
   ZajednickaVarijabla = (int *) shmat(Id, NULL, 0);
   *ZajednickaVarijabla = 0;
   sigset(SIGINT, brisi);//u slučaju prekida briši memoriju
 
   /* pokretanje paralelnih procesa */
   if (fork() == 0) {
      Citac();
      exit(0);
   }
   if (fork() == 0) {
      sleep(5);
      Pisac(123);
      exit(0);
   }
   (void) wait(NULL);
   (void) wait(NULL);
   brisi(0);
 
   return 0;
}
[ Texas Instruments @ 22.05.2015. 23:17 ] @
Recimo na početku programa možeš da ispišeš ime sistema, verziju, arhitekturu...

Code:

#include <sys/utsname.h>
...
struct utsname u;
uname(&u);
printf("%s release %s (version %s) on %s\n", u.sysname, u.release, u.version, u.machine);
...
[ DusanSukovic @ 16.09.2015. 13:07 ] @
Citat:

If you don't know where to start, type man intro, or man -s <section> intro. This gives you a summary of commands of requested section.

Sections are well defined:

1 is for shell commands,
2 is for system calls,
3 is for programming interfaces (sometimes 3C for C, 3F for Fortran...)
5 is for file formats and other rules such as printf or regex formats.

Last but not least: information delivered in man pages is not redundant, so read carefully from beginning to end for increasing your chances to find what you need.



http://unix.stackexchange.com/...nding-information-in-man-pages