main.cpp 724 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include <QCoreApplication>
  2. #include "writeshm.h"
  3. #include "dogcore.h"
  4. #include <QDir>
  5. #include <QFile>
  6. DataWriteShm *dataWriteShm;
  7. bool load_shm(){
  8. int shmid;
  9. key_t key;
  10. if((key=ftok(IPC_PATH,static_cast<int>(IPC_PORT)))==-1){
  11. return false;
  12. }
  13. if((shmid=shmget(key,sizeof(DataWriteShm),IPC_CREAT|0666))==-1){
  14. return false;
  15. }
  16. dataWriteShm = static_cast<DataWriteShm *>(shmat(shmid,nullptr,0));
  17. return true;
  18. }
  19. int main(int argc, char *argv[])
  20. {
  21. QCoreApplication a(argc, argv);
  22. if(load_shm()){
  23. DogCore *dogcore = new DogCore(nullptr);
  24. dogcore->start();
  25. }else{
  26. fprintf(stderr,"load shm err");
  27. exit(1);
  28. }
  29. return a.exec();
  30. }