我在 xv6 中进行了系统调用,并试图更改进程名称。进程名称存在于如下所示的 proc 结构中:
// Per-process state
struct proc {
uint sz; // Size of process memory (bytes)
pde_t* pgdir; // Page table
char *kstack; // Bottom of kernel stack for this process
enum procstate state; // Process state
volatile int pid; // Process ID
struct proc *parent; // Parent process
struct trapframe *tf; // Trap frame for current syscall
struct context *context; // swtch() here to run process
void *chan; // If non-zero, sleeping on chan
int killed; // If non-zero, have been killed
struct file *ofile[NOFILE]; // Open files
struct inode *cwd; // Current directory
char name[16]; // Process name (debugging)
};
我尝试使用以下代码访问该名称,并为其分配一个值:
void modifyCurrentProcessName(char* newName)
{
proc->name= &newName;
}
我收到以下错误:
proc.c:在函数“modifyCurrentProcessName”中:proc.c:490:15:错误:赋值给数组类型为 proc->name= &newName; 的表达式 ^ : 目标 'proc.o' 的配方失败 make: *** [proc.o] 错误 1