main.cpp 721 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #include <QCoreApplication>
  2. #include "../ytCore/yt_unit_shm.h"
  3. #include "dogthread.h"
  4. YT_UNIT_SHM *ytShm;
  5. bool load_shm()
  6. {
  7. int shmid;
  8. key_t key;
  9. if((key = ftok(SHM_PATH,(int)SHM_PORT))==-1)
  10. return false;
  11. if((shmid = shmget(key,sizeof(YT_UNIT_SHM),IPC_CREAT|0666))==-1)
  12. return false;
  13. ytShm = (YT_UNIT_SHM *)shmat(shmid,NULL,0);
  14. return true;
  15. }
  16. int main(int argc, char *argv[])
  17. {
  18. QCoreApplication a(argc, argv);
  19. QStringList params;
  20. if(argc>1)
  21. {
  22. for(int i=1;i<argc;i++)
  23. params.append(QString(argv[i]));
  24. }
  25. if(load_shm())
  26. {
  27. dogThread *thread = new dogThread(0,params);
  28. thread->start();
  29. }
  30. return a.exec();
  31. }