It is currently Sat Jul 04, 2020 1:47 pm

All times are UTC + 1 hour

Post new topic Reply to topic  [ 1 post ] 
Author Message
 Post subject: Linux Open_() Problems
PostPosted: Mon Oct 23, 2017 9:54 pm 

Joined: Thu May 21, 2009 6:56 pm
Posts: 579

I am trying to understand how to use Linux functions in Purebasic. So I wanted to open a file and see if I could lock it. However, the File Descriptor returned from the open_() functions is always -1. There was one occasion when it was a positive value but I have not been able to repeat it. Can anyone see what is wrong with my code? I am new to Linux so I have lots to learn.

ImportC ""
   errno_location() As "__errno_location"

lcPath.s = GetCurrentDirectory()
Debug lcpath

lnF.i= open_(lcPath+"",O_CREAT + O_RDWR,"0666")

;lnF.i = CreateFile(1,lcPath+"",#PB_File_NoBuffering | #PB_Ascii)

Debug lnF

Structure Lock

Define loLock.Lock

loLock\l_type = F_RDLCK   ; F_WRLCK = 1, F_UNLCK = 2, F_RDLCK = 0
loLock\l_whence = SEEK_SET ; SEEK_SET = 0
lolock\l_start = 0
loLock\l_len = 0
loLock\l_pid = getpid_()

lnLck.i = fcntl_(lnF,F_SETLCK,@loLock)
Debug PeekL(errno_location())

;lnLck.i = flock(lnID,1) ;LOCK_SH   1, LOCK_EX   2, LOCK_NB   4, LOCK_UN   8
Debug lnLck

Simon White
dCipher Computing

Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC + 1 hour

Who is online

Users browsing this forum: No registered users and 6 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye