mirror of
				https://github.com/xcat2/xcat-core.git
				synced 2025-10-30 10:52:31 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			23 lines
		
	
	
		
			396 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
			
		
		
	
	
			23 lines
		
	
	
		
			396 B
		
	
	
	
		
			Perl
		
	
	
	
	
	
| package TEAL::Semaphore;
 | |
| 
 | |
| use strict;
 | |
| use warnings;
 | |
| require IPC::SysV;
 | |
| 
 | |
| sub new {
 | |
|     my $class = shift;
 | |
|     my $self  = {};
 | |
|     my $key   = IPC::SysV::ftok("/var/log/teal", 0x646c6100);
 | |
|     $self->{ID} = semget($key, 1, 0);
 | |
|     bless $self, $class;
 | |
|     return $self;
 | |
| }
 | |
| 
 | |
| sub post {
 | |
|     my $self = shift;
 | |
|     my $op = pack("s!3", 0, 1, 0);
 | |
|     semop $self->{ID}, $op || die "failed to post"
 | |
| }
 | |
| 
 | |
| 1;
 |